Skip to content

fix(core): Prevent unhandled promise rejection in withMonitor #16753

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
wants to merge 1 commit into from

Conversation

RulaKhaled
Copy link
Member

Problem

withMonitor function was causing unhandled promise rejections when wrapping async callbacks that throw errors. This could crash servers when monitoring async operations.

When a promise returned by the callback rejected, the error was being thrown inside the promise rejection handler:

Promise.resolve(maybePromiseResult).then(
  () => { finishCheckIn('ok'); },
  e => {
    finishCheckIn('error');
    throw e;  // This causes unhandled rejection
  },
);

Solution

Simply remove the throw e; line. The original promise is already returned to the caller, so they can handle the rejection appropriately.

Fixes #JS-620

@RulaKhaled RulaKhaled marked this pull request as draft June 27, 2025 09:16
Copy link

codecov bot commented Jun 27, 2025

❌ Unsupported file format

Upload processing failed due to unsupported file format. Please review the parser error message:
Error deserializing json

Caused by:
expected value at line 1 column 1

For more help, visit our troubleshooting guide.

@RulaKhaled RulaKhaled closed this Jun 27, 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.

1 participant