Skip to content

Commit 1a73375

Browse files
committed
[Diagnostics] Add EventSource Callback Possible Deadlock Warning
1 parent e83ca1c commit 1a73375

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

docs/core/diagnostics/eventsource.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ your own custom events.
2020
> Many technologies that integrate with EventSource use the terms 'Tracing' and 'Traces' instead of 'Logging' and 'Logs'.
2121
> The meaning is the same here.
2222
23+
> [!WARNING] Potential Deadlocks with EventSource Callbacks
24+
>
25+
> When implementing EventSources, be cautious with invoking lock-acquiring APIs within EventSource callbacks. EventSource instances are initialized early in the runtime, before some core features are fully initialized. As a result, the re-entrant behavior of EventSource callbacks may cause deadlocks if the callback attempts to acquire locks already held by the thread that triggered the callback.
26+
>
27+
> To mitigate this risk, consider the following precautions:
28+
>
29+
> - **Avoid Complex Operations**: Refrain from performing complex operations within the callback that might acquire additional locks.
30+
> - **Minimize Lock Duration**: Ensure that any locks acquired within the callback are not held for extended periods.
31+
> - **Use Non-blocking APIs**: Prefer using non-blocking APIs within the callback to avoid potential deadlocks.
32+
2333
- [Getting started](./eventsource-getting-started.md)
2434
- [Instrumenting code to create events](./eventsource-instrumentation.md)
2535
- [Collecting and viewing event traces](./eventsource-collect-and-view-traces.md)

0 commit comments

Comments
 (0)