8000 Reject promises for workers that are about to be killed by wanaryytel · Pull Request #170 · alewin/useWorker · GitHub
[go: up one dir, main page]

Skip to content

Reject promises for workers that are about to be killed - #170

Merged
alewin merged 1 commit into
alewin:masterfrom
wanaryytel:reject-killed-promises-to-avoid-dangling-promises
Mar 9, 2025
Merged

alewin merged 1 commit into
alewin:masterfrom
wanaryytel:reject-killed-promises-to-avoid-dangling-promises

Conversation

@wanaryytel
Copy link
Copy Markdown
Contributor

Currently the promises for workers that are killed are left dangling which is problematic because dangling promises can result in memory leaks and other bad outcomes. A simple way to avoid that is to reject the promise with a specific AbortError that the user can catch and handle as they please. This is also the approach that axios is using for example for the same case if you kill a request before it returns a response.

Currently the promises for workers that are killed are left
dangling which is problematic because dangling promises
can result in memory leaks and other bad outcomes.
A simple way to avoid that is to reject the promise
with a specific AbortError that the user can catch
and handle as they please. This is also the approach
that axios is using for example for the same case
if you kill a request before it returns a response.
@pkg-pr-new
pkg-pr-new Bot commented Mar 7, 2025
Copy link
Copy Markdown

Open in Stackblitz

npm i https://pkg.pr.new/alewin/useWorker/@koale/useworker@170

commit: f4cab57

@alewin alewin left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

excellent!

@alewin
alewin merged commit 6235053 into alewin:master Mar 9, 2025
@github-actions github-actions Bot mentioned this pull request Mar 9, 2025
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.

2 participants

0