Fix unhandled promise rejection in whitespace-async.js by 19kumarashish · Pull Request #3276 · airbnb/javascript · GitHub
Skip to content

Fix unhandled promise rejection in whitespace-async.js#3276

Closed
19kumarashish wants to merge 1 commit into
airbnb:masterfrom
19kumarashish:bug/3237-whitespace-async
Closed

Fix unhandled promise rejection in whitespace-async.js#3276
19kumarashish wants to merge 1 commit into
airbnb:masterfrom
19kumarashish:bug/3237-whitespace-async

Conversation

@19kumarashish

Copy link
Copy Markdown

Summary

This pull request fixes the unhandled promise rejection in whitespace-async.js when the ESLint async path is used.

Problem

onlyErrorOnRules(...) returns a Promise, but the current implementation only handles the fulfilled case using .then(). If the Promise rejects, the rejection becomes unhandled, which may cause the child process to exit unexpectedly or produce unclear error messages.

Solution

  • Add a .catch() handler to the Promise chain.
  • Log the error using console.error().
  • Set process.exitCode = 1 so the process exits with a non-zero status instead of leaving the rejection unhandled.

Testing

  • Verified that successful execution is unaffected.
  • Verified that rejected Promises are handled gracefully.
  • Confirmed that the process exits with code 1 instead of producing an unhandled promise rejection warning.

Fixes #3237

daltino

This comment was marked as spam.

@ljharb

ljharb commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

@ljharb ljharb closed this Jun 26, 2026
@19kumarashish

Copy link
Copy Markdown
Author

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.

Severity: Unhandled promise rejection in whitespace-async.js when ESLint async path is used

4 participants