Skip to content

Report a promise rejection as uncaught only if it is still unhandled after the jobs around it - #524

Draft
wesgarland wants to merge 2 commits into
mainfrom
wes/fix/handled-rejection-reported-uncaught
Draft

wesgarland wants to merge 2 commits into
mainfrom
wes/fix/handled-rejection-reported-uncaught

Conversation

@wesgarland

Copy link
Copy Markdown
Collaborator

promiseRejectionTracker reported every rejection SpiderMonkey marked Unhandled straight away and ignored the Handled state. Promise.prototype.finally() rejects an internal promise that only gets its handler a few jobs later, so p.finally(f).catch(h) was reported as Uncaught even though h ran, and pmjs then stopped its event loop and exited 1. dcp-client's job.exec() returns such a chain, so cancelling a job killed the program.

  • Unhandled rejections are kept (rooted) until a check scheduled with call_later(0) runs after the jobs queued around them; a Handled notification in between removes them. The check is counted as a pending job, so pm.wait() waits for it.
  • tests/js/finally-rejection-handled.simple: three rejections handled through finally(); fails on 1.5.1.
  • tests/js/unhandled-rejection.bash: a rejection nobody handles is still reported and pmjs still exits non-zero; passes on 1.5.1 and must keep passing.

Not built locally; CI is the first build.

…after the jobs around it

promiseRejectionTracker reported every Unhandled rejection at once and ignored the Handled state, so
a rejection handled through Promise.prototype.finally() (whose internal promise gets its handler a
few jobs later) was reported as uncaught, and pmjs stopped and exited 1.

This branch has not been deployed

No deployments
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.

1 participant