Commit activity
Last 12 weeks · 14 commits
Community health
4 of 6 standards met
Recent fixes
A timeout with fulfills with the fallback value without calling the input promise's . With and no fallback, the timeout calls and fulfills with . The README and type documentation describe cancellation on timeout without a fallback exception. The fallback branch returns before the call to . Reproduced with unmodified source at (package version 7.0.2), Node.js v24.21.0, Linux x64. Save this as in the repository root. It uses the public option to trigger the timeout directly: Run: Both results are printed and the control assertions pass before the final assertion fails with exit code 1. Relevant output, with the stack omitted: I also checked with the input resolved after the timeout: it currently fulfills successfully without calling . Canceling the input before invoking the fallback would change that behavior. Should every timeout cancel the input, including when is provided, or should the documentation state that a fallback takes responsibility for cancellation? This seems worth clarifying before changing the behavior.
When is already aborted, rejects its wrapper before attaching a rejection handler to the input promise. If that input rejects, it becomes an unhandled rejection even when the caller catches the wrapper's cancellation. Under Node's strict unhandled-rejection mode, this terminates the process. Attach handlers to the input in the pre-aborted branch after rejecting with the cancellation reason. This consumes a later input rejection while keeping cancellation as the wrapper's result. Validation: passes (XO, 21 runtime tests, and tsd). The regression runs a child process with for finite and infinite timeouts, verifying both a clean exit and preservation of the abort reason. The child process fails before the fix. AI assistance: OpenAI Codex assisted with diagnosis, implementation, and testing.
Upgrading from to , I get errors in my console: It seems the same error that #18 solved. I see in the diff that goes back to calling directly (instead of calling via ), so I'm guessing that's the issue. No idea what's the correct approach, though. Additional context My usage of is pretty vanilla: Screenshots of my console:
Repository: sindresorhus/p-timeout. Description: Timeout a promise after a specified amount of time Stars: 308, Forks: 34. Primary language: JavaScript. Languages: JavaScript (94.7%), TypeScript (5.3%). License: MIT. Latest release: v8.0.0 (6d ago). Open PRs: 0, open issues: 0. Last activity: 6d ago. Community health: 85%. Top contributors: sindresorhus, ronami, BendingBender, fregante, jopemachine, Kikobeats, buschtoens, jonidelv, kevva, xianjianlf2 and others.