Commit 90a6a25
authored
fix(core): Explicitly flush log buffer in
Adds an explicit `_INTERNAL_flushLogsBuffer(this)` call at the start of
the base Client.close() method, before flush(timeout) is called.
Previously, the log buffer flush during `close()` relied on an indirect
event chain: `close() → flush() → emit('flush') →
setupWeightBasedFlushing handler → _INTERNAL_flushLogsBuffer`. While
this works, it's fragile and could break if someone refactors the event
mechanism. The explicit call ensures logs are always flushed on close
regardless of the event wiring.
The call is placed before flush() so the log envelope is queued to the
transport before transport.flush(timeout) drains all pending sends.
_INTERNAL_flushLogsBuffer safely handles empty buffers (returns early),
so there's no overhead when logs are disabled or the buffer is empty.
All platform SDKs (NodeClient, LightNodeClient, DenoClient,
BrowserClient, CloudflareClient) ultimately call super.close() which
reaches this base implementation, so all runtimes benefit automatically.
closes #19347client.close() (#19371)1 parent afba737 commit 90a6a25
2 files changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
448 | 449 | | |
449 | 450 | | |
450 | 451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
2212 | 2213 | | |
2213 | 2214 | | |
2214 | 2215 | | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
2215 | 2234 | | |
2216 | 2235 | | |
2217 | 2236 | | |
| |||
0 commit comments