Commit a13d17d
committed
fix(diagnostics): fire asyncStart synchronously, asyncEnd in finally
maybeTraceMixed was firing asyncStart and asyncEnd back-to-back inside
the .then callback. That left no meaningful window between the two
events: for APM subscribers, 'async work begins' and 'async work
completes' fired in the same microtask, making the pair useless for
measuring the async duration.
Correct shape: asyncStart publishes synchronously as soon as we know
the operation is in-flight asynchronously (right after end), and
asyncEnd publishes in a .finally after settlement. Both the .then and
.finally are attached inside start.runStores, so AsyncLocalStorage
context is preserved end-to-end via async_hooks.
Event order now:
sync path: [start, end]
async path: [start, end, asyncStart, ..., asyncEnd]
async error: [start, end, asyncStart, error, asyncEnd]
Mirrors the same fix in the FakeTracingChannel helper.1 parent 4855e1e commit a13d17d
2 files changed
+29
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
140 | 135 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
146 | 141 | | |
147 | 142 | | |
148 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
243 | 244 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
253 | 249 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
259 | 255 | | |
260 | 256 | | |
0 commit comments