Skip to content

fix: settle promises before invoking callbacks - #600

Open
edsonsims wants to merge 1 commit into
josdejong:masterfrom
edsonsims:fix/pending-finally-settlement
Open

edsonsims wants to merge 1 commit into
josdejong:masterfrom
edsonsims:fix/pending-finally-settlement

Conversation

@edsonsims

Copy link
Copy Markdown

When .finally() is attached before a promise settles, its callback can run while the chained promise stays pending. Handlers attached from a settling callback can also be stranded.

I set the terminal handler dispatch and disable further settlement before delivering callbacks, so reentrant handlers observe the original outcome and cannot overwrite it.

Fixes #596.

Validation: all six regressions fail on the original source. npm test passes with 176 tests passing and two existing pending tests, including the build and type checks. Local worker-thread and child-process probes also complete the pending .finally() chain. Tested on Node 24.19.0/macOS; browser and other platform runs are left to CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Promise.prototype.finally() never settles when the promise resolves after .finally() is attached

1 participant