You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logger.traced ends spans before promises from another realm settle #2753
runCatchFinally checks asynchronous results with "ret instanceof Promise". A native Promise created in another JavaScript realm, such as Node's vm context, fails that check.
Logger.traced therefore calls span.end() immediately when the callback returns a still-pending foreign Promise. Rejection also bypasses the error handler. A conforming thenable without catch/finally methods has the same premature-cleanup behavior.
I reproduced this against current main with real package tests:
A Node vm Promise is still pending, but a spy on the public Logger.traced span's end method already records one call.
The helper's cleanup runs before fulfillment.
A rejected foreign Promise never reaches the helper's catch handler.
A then-only PromiseLike also triggers immediate cleanup.
The new focused Vitest tests produce four failures and five passes on the unchanged implementation, including a passing synchronous-return/error control. The logger test uses the SDK's in-memory test logger; it does not call a model or require service credentials.
I plan to recognize PromiseLike results, preserve normal Promise chaining (including subclass behavior), assimilate then-only values when necessary, and add the regression coverage and a patch changeset. I will run the package typing and relevant test checks before opening a PR.
AI assistance: Codex helped inspect the helper and execute these reproductions.
Activity