Commit 4c52da8
fix(server-utils): Don't capture AI client errors as unhandled at the instrumentation level
The exported instrumentOpenAiClient, instrumentAnthropicAiClient and
instrumentGoogleGenAIClient wrappers captured provider errors with
mechanism.handled = false and then rethrew, so the SDK classified the
error as an unhandled crash before the application's retry or fallback
logic ran. A call that succeeded on retry still produced an unhandled
event, and each retry produced another one.
Applies the convention established for the channel-based OpenAI
integration in #21877 to the manual client instrumentation, which is the
only available path on the edge and serverless runtimes. Error span
status and the original error identity are unchanged.
The anthropic suite asserted this divergence directly, expecting the
model-error event only while orchestrion was disabled. Both paths agree
now, so that branch and its expectation are gone.
Captures are kept where a provider reports an error as data on an
otherwise successful call, since the caller never sees those as a thrown
error. The AI integration suites no longer mask these events with
.ignore('event'), so they fail if the capture returns.
Dropping the capture also left the .catch() in createWithResponseWrapper
rethrowing into a promise nothing observes, which is not a handler at
all: awaiting the two promises in sequence orphans the second whenever
the first rejects. They are awaited together now.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 05a0fe4 commit 4c52da8
11 files changed
Lines changed: 169 additions & 171 deletions
File tree
- dev-packages/node-integration-tests/suites/tracing
- anthropic
- google-genai
- openai
- openai-tool-calls
- v6
- packages/server-utils
- src/ai
- anthropic-ai
- core
- google-genai
- openai
- test/ai
- lib/tracing/ai
- tracing
Lines changed: 5 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 40 | | |
53 | 41 | | |
54 | 42 | | |
55 | 43 | | |
56 | 44 | | |
57 | 45 | | |
58 | 46 | | |
59 | | - | |
60 | 47 | | |
61 | 48 | | |
62 | 49 | | |
| |||
92 | 79 | | |
93 | 80 | | |
94 | 81 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 82 | + | |
104 | 83 | | |
105 | 84 | | |
106 | 85 | | |
| |||
142 | 121 | | |
143 | 122 | | |
144 | 123 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 124 | + | |
154 | 125 | | |
155 | 126 | | |
156 | 127 | | |
| |||
220 | 191 | | |
221 | 192 | | |
222 | 193 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 194 | + | |
232 | 195 | | |
233 | 196 | | |
234 | 197 | | |
| |||
296 | 259 | | |
297 | 260 | | |
298 | 261 | | |
299 | | - | |
300 | 262 | | |
301 | 263 | | |
302 | 264 | | |
| |||
350 | 312 | | |
351 | 313 | | |
352 | 314 | | |
353 | | - | |
354 | 315 | | |
355 | 316 | | |
356 | 317 | | |
| |||
401 | 362 | | |
402 | 363 | | |
403 | 364 | | |
404 | | - | |
405 | 365 | | |
406 | 366 | | |
407 | 367 | | |
| |||
432 | 392 | | |
433 | 393 | | |
434 | 394 | | |
435 | | - | |
436 | 395 | | |
437 | 396 | | |
438 | 397 | | |
| |||
462 | 421 | | |
463 | 422 | | |
464 | 423 | | |
465 | | - | |
466 | 424 | | |
467 | 425 | | |
468 | 426 | | |
| |||
503 | 461 | | |
504 | 462 | | |
505 | 463 | | |
| 464 | + | |
| 465 | + | |
506 | 466 | | |
507 | 467 | | |
508 | 468 | | |
| |||
551 | 511 | | |
552 | 512 | | |
553 | 513 | | |
554 | | - | |
555 | 514 | | |
556 | 515 | | |
557 | 516 | | |
| |||
590 | 549 | | |
591 | 550 | | |
592 | 551 | | |
593 | | - | |
594 | 552 | | |
595 | 553 | | |
596 | 554 | | |
| |||
614 | 572 | | |
615 | 573 | | |
616 | 574 | | |
617 | | - | |
618 | 575 | | |
619 | 576 | | |
620 | 577 | | |
| |||
Lines changed: 2 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
86 | 85 | | |
87 | 86 | | |
88 | 87 | | |
89 | | - | |
90 | 88 | | |
91 | 89 | | |
92 | 90 | | |
| |||
137 | 135 | | |
138 | 136 | | |
139 | 137 | | |
140 | | - | |
141 | 138 | | |
142 | 139 | | |
143 | 140 | | |
| |||
174 | 171 | | |
175 | 172 | | |
176 | 173 | | |
177 | | - | |
178 | 174 | | |
179 | 175 | | |
180 | 176 | | |
| |||
233 | 229 | | |
234 | 230 | | |
235 | 231 | | |
| 232 | + | |
236 | 233 | | |
237 | 234 | | |
238 | 235 | | |
| |||
289 | 286 | | |
290 | 287 | | |
291 | 288 | | |
| 289 | + | |
292 | 290 | | |
293 | 291 | | |
294 | 292 | | |
| |||
348 | 346 | | |
349 | 347 | | |
350 | 348 | | |
351 | | - | |
352 | 349 | | |
353 | 350 | | |
354 | 351 | | |
| |||
372 | 369 | | |
373 | 370 | | |
374 | 371 | | |
375 | | - | |
376 | 372 | | |
377 | 373 | | |
378 | 374 | | |
| |||
411 | 407 | | |
412 | 408 | | |
413 | 409 | | |
414 | | - | |
415 | 410 | | |
416 | 411 | | |
417 | 412 | | |
| |||
458 | 453 | | |
459 | 454 | | |
460 | 455 | | |
461 | | - | |
462 | 456 | | |
463 | 457 | | |
464 | 458 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
| |||
326 | 325 | | |
327 | 326 | | |
328 | 327 | | |
329 | | - | |
330 | 328 | | |
331 | 329 | | |
332 | 330 | | |
| |||
Lines changed: 0 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
333 | 332 | | |
334 | 333 | | |
335 | 334 | | |
336 | | - | |
337 | 335 | | |
338 | 336 | | |
339 | 337 | | |
| |||
681 | 679 | | |
682 | 680 | | |
683 | 681 | | |
684 | | - | |
685 | 682 | | |
686 | 683 | | |
687 | 684 | | |
| |||
726 | 723 | | |
727 | 724 | | |
728 | 725 | | |
729 | | - | |
730 | 726 | | |
731 | 727 | | |
732 | 728 | | |
| |||
859 | 855 | | |
860 | 856 | | |
861 | 857 | | |
862 | | - | |
863 | 858 | | |
864 | 859 | | |
865 | 860 | | |
| |||
1089 | 1084 | | |
1090 | 1085 | | |
1091 | 1086 | | |
1092 | | - | |
1093 | 1087 | | |
1094 | 1088 | | |
1095 | 1089 | | |
| |||
1209 | 1203 | | |
1210 | 1204 | | |
1211 | 1205 | | |
1212 | | - | |
1213 | 1206 | | |
1214 | 1207 | | |
1215 | 1208 | | |
| |||
1242 | 1235 | | |
1243 | 1236 | | |
1244 | 1237 | | |
1245 | | - | |
1246 | 1238 | | |
1247 | 1239 | | |
1248 | 1240 | | |
| |||
1274 | 1266 | | |
1275 | 1267 | | |
1276 | 1268 | | |
1277 | | - | |
1278 | 1269 | | |
1279 | 1270 | | |
1280 | 1271 | | |
| |||
1310 | 1301 | | |
1311 | 1302 | | |
1312 | 1303 | | |
1313 | | - | |
1314 | 1304 | | |
1315 | 1305 | | |
1316 | 1306 | | |
| |||
1337 | 1327 | | |
1338 | 1328 | | |
1339 | 1329 | | |
1340 | | - | |
1341 | 1330 | | |
1342 | 1331 | | |
1343 | 1332 | | |
| |||
1368 | 1357 | | |
1369 | 1358 | | |
1370 | 1359 | | |
1371 | | - | |
1372 | 1360 | | |
1373 | 1361 | | |
1374 | 1362 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
| |||
346 | 345 | | |
347 | 346 | | |
348 | 347 | | |
349 | | - | |
350 | 348 | | |
351 | 349 | | |
352 | 350 | | |
| |||
704 | 702 | | |
705 | 703 | | |
706 | 704 | | |
707 | | - | |
708 | 705 | | |
709 | 706 | | |
710 | 707 | | |
| |||
767 | 764 | | |
768 | 765 | | |
769 | 766 | | |
770 | | - | |
771 | 767 | | |
772 | 768 | | |
773 | 769 | | |
| |||
910 | 906 | | |
911 | 907 | | |
912 | 908 | | |
913 | | - | |
914 | 909 | | |
915 | 910 | | |
916 | 911 | | |
| |||
0 commit comments