feat: Add withTimeout helper#70
Conversation
|
Let's add this method to the readme as well |
There was a problem hiding this comment.
Pull request overview
Adds a withTimeout helper to the async utilities library to bound async operations by a deadline, along with a dedicated TimeoutError type and accompanying unit tests.
Changes:
- Introduce
TimeoutErrorandwithTimeout()inlib/asyncbox.ts. - Add
withTimeoutbehavioral tests (success, timeout, custom message, custom error, propagation of underlying rejection).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/asyncbox.ts |
Adds TimeoutError plus withTimeout() implementation and typings. |
test/asyncbox-specs.ts |
Adds Mocha/Chai tests validating withTimeout() behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Added |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| reject(new TimeoutError(messageOrError)); | ||
| } else if (!messageOrError) { | ||
| reject(new TimeoutError(`Operation timed out after ${timeoutMs}ms`)); | ||
| } else { |
There was a problem hiding this comment.
Not sure if we should guard this branch against non-Error types
There was a problem hiding this comment.
for now I would keep it as is. Not sure if it ever would become an issue
## [6.2.0](v6.1.0...v6.2.0) (2026-05-03) ### Features * Add withTimeout helper ([#70](#70)) ([12b4b2f](12b4b2f))
|
🎉 This PR is included in version 6.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.