fix: handle unhandled promise rejections in whitespace-async.js#3245
Open
sinteticx wants to merge 3 commits intoairbnb:masterfrom
Open
fix: handle unhandled promise rejections in whitespace-async.js#3245sinteticx wants to merge 3 commits intoairbnb:masterfrom
sinteticx wants to merge 3 commits intoairbnb:masterfrom
Conversation
Add .catch() handlers to promise chains in whitespace-async.js files to prevent unhandled rejections and provide clear error messages.
…e errors gracefully:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add .catch() handlers to promise chains in whitespace-async.js files to prevent unhandled rejections and provide clear error messages.
Summary
Fix unhandled promise rejections in
whitespace-async.jsscripts that occur when ESLint 9 loads the config or when CLIEngine is unavailable.Problem
The
onlyErrorOnRules(...).then(...)promise chain lacked a.catch()handler. If the promise rejects, it causes an unhandled rejection, potentially crashing the process. Additionally, child process errors or non-JSON output could causeJSON.parse(stdout)to fail with unclear errors during config loading.Solution
Added
.catch()handlers to log errors to stderr and exit with code 1, ensuring graceful failure and better error visibility.Files Changed
packages/eslint-config-airbnb-base/whitespace-async.jspackages/eslint-config-airbnb/whitespace-async.jsTesting
Verified scripts run without unhandled rejections in both packages.