Skip to content

Commit 33cd37b

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

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/core/diagnostics/eventsource.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ 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]
24+
> Potential Deadlocks with EventSource Callbacks
25+
>
26+
> 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.
27+
>
28+
> To mitigate this risk, consider the following precautions:
29+
>
30+
> - **Avoid Complex Operations**: Refrain from performing complex operations within the callback that might acquire additional locks.
31+
> - **Minimize Lock Duration**: Ensure that any locks acquired within the callback are not held for extended periods.
32+
> - **Use Non-blocking APIs**: Prefer using non-blocking APIs within the callback to avoid potential deadlocks.
33+
2334
- [Getting started](./eventsource-getting-started.md)
2435
- [Instrumenting code to create events](./eventsource-instrumentation.md)
2536
- [Collecting and viewing event traces](./eventsource-collect-and-view-traces.md)

0 commit comments

Comments
 (0)