Skip to content

feat(common): use addEventListener instead of onabort in async utils onAbortPromise #645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Prev Previous commit
Next Next commit
Consolidate logic by calling abortHandler() if signal is already aborted
  • Loading branch information
douglascayers committed Jun 29, 2025
commit d08cc0863f441cd3bb1e5ded724582bdeb3fac78
4 changes: 3 additions & 1 deletion packages/common/src/utils/async.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { abort } from 'process';

/**
* Throttle a function to be called at most once every "wait" milliseconds,
* on the trailing edge.
Expand Down Expand Up @@ -90,7 +92,7 @@ export function resolveEarlyOnAbort<T>(
addAbortHandler();

if (signal.aborted) {
resolveWith({ aborted: true });
abortHandler();
return;
}

Expand Down