Commit 1553944
TS: defer FFI callback unregister to avoid DEP0168 at teardown
The in-process cell is green, but teardown emitted repeated DEP0168 "Uncaught
Node-API callback exception" warnings. They come from inside koffi, not the
SDK's callbacks (the guards added alongside never logged): koffi delivers the
native outbound callback from a secondary thread by queuing it onto the event
loop, and at teardown one such delivery can still be queued when dispose() calls
koffi.unregister synchronously. Unregistering while a queued call is pending
makes koffi invoke a freed callback and raise inside its own native code, which
no JS try/catch can intercept.
Defer the unregister to a setImmediate: the native connection and host are
already closed by then, so no new deliveries originate, and a pending delivery
fires in libuv's poll phase with the callback still valid (it no-ops since we're
disposed) before the check-phase setImmediate frees the slot. The immediate is
unref'd so it never keeps the process alive.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 02e407b commit 1553944
1 file changed
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
372 | | - | |
373 | | - | |
| 371 | + | |
| 372 | + | |
374 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
375 | 396 | | |
376 | 397 | | |
377 | 398 | | |
| |||
0 commit comments