Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 3e7e7da

Browse files
committed
Clarify risks associated with waiting on child coroutines in a Scope and provide guidance for safe usage in web server applications
1 parent 388e79c commit 3e7e7da

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

basic.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,9 @@ function fetchFirstSuccessful(string ...$apiHosts): string
254254
}
255255
```
256256

257-
258257
### Implementation requirements
259258

260-
The implementation of this **RFC** should be carried out in a way that minimizes changes to the **PHP** core.
259+
The implementation of this **RFC** should be carried out in a way that minimizes changes to the **PHP core**.
261260

262261
The proposed changes include:
263262
* syntax modifications to the language,
@@ -1938,6 +1937,14 @@ This illustrates the key idea of structured concurrency:
19381937
tying the lifetime of child tasks to the scope that allocates resources.
19391938
Both the child tasks and the resources must be cleaned up in a well-defined order.
19401939

1940+
Waiting for all child coroutines in a `Scope` is **a dangerous operation**,
1941+
as in the case of a **zombie coroutine**, memory and descriptor resources may be held indefinitely.
1942+
This approach is only acceptable in scenarios where the user can cancel the operation,
1943+
such as during the execution of **console commands**.
1944+
1945+
In the context of web server applications, you **should not** wait on a `Scope`
1946+
unless it is part of a **Supervisor** strategy.
1947+
19411948
### Error detection
19421949

19431950
Detecting erroneous situations when using coroutines is an important part of analyzing an application's reliability.

0 commit comments

Comments
 (0)