Skip to content

feat: Add withTimeout helper#70

Merged
mykola-mokhnach merged 3 commits into
masterfrom
timeout
May 3, 2026
Merged

feat: Add withTimeout helper#70
mykola-mokhnach merged 3 commits into
masterfrom
timeout

Conversation

@mykola-mokhnach
Copy link
Copy Markdown
Contributor

No description provided.

@eglitise eglitise requested a review from Copilot May 3, 2026 16:32
@eglitise
Copy link
Copy Markdown
Contributor

eglitise commented May 3, 2026

Let's add this method to the readme as well

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TimeoutError and withTimeout() in lib/asyncbox.ts.
  • Add withTimeout behavioral 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.

Comment thread lib/asyncbox.ts
Comment thread test/asyncbox-specs.ts
@mykola-mokhnach
Copy link
Copy Markdown
Contributor Author

Let's add this method to the readme as well

Added

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread lib/asyncbox.ts
reject(new TimeoutError(messageOrError));
} else if (!messageOrError) {
reject(new TimeoutError(`Operation timed out after ${timeoutMs}ms`));
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should guard this branch against non-Error types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now I would keep it as is. Not sure if it ever would become an issue

@mykola-mokhnach mykola-mokhnach merged commit 12b4b2f into master May 3, 2026
9 checks passed
@mykola-mokhnach mykola-mokhnach deleted the timeout branch May 3, 2026 17:21
github-actions Bot pushed a commit that referenced this pull request May 3, 2026
## [6.2.0](v6.1.0...v6.2.0) (2026-05-03)

### Features

* Add withTimeout helper ([#70](#70)) ([12b4b2f](12b4b2f))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

🎉 This PR is included in version 6.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants