Skip to content

fix: handle unhandled promise rejections in whitespace-async.js#3245

Open
sinteticx wants to merge 3 commits intoairbnb:masterfrom
sinteticx:fix-#3237
Open

fix: handle unhandled promise rejections in whitespace-async.js#3245
sinteticx wants to merge 3 commits intoairbnb:masterfrom
sinteticx:fix-#3237

Conversation

@sinteticx
Copy link

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.js scripts 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 cause JSON.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.js
  • packages/eslint-config-airbnb/whitespace-async.js

Testing

Verified scripts run without unhandled rejections in both packages.

Add .catch() handlers to promise chains in whitespace-async.js files
to prevent unhandled rejections and provide clear error messages.
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