-
-
Couldn't load subscription status.
- Fork 705
Handle jsPlugin failures #15011
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
base: main
Are you sure you want to change the base?
Handle jsPlugin failures #15011
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves error handling for JS Plugin failures by adding proper cleanup and validation logic. Previously, when a JS Plugin failed, internal state would remain corrupted, leading to errors that pointed to Oxlint internals rather than the actual JS error source.
Key Changes:
- Added comprehensive state cleanup in
initCompiledVisitorto handle previous compilation failures - Added input validation in
mergeVisitFnsto catch invalid data early with clear error messages
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function mergeVisitFns(visitFns: VisitFn[]): VisitFn { | ||
| // Validate that visitFns is actually an array | ||
| if (!isArray(visitFns)) { | ||
| throw new TypeError(`Expected visitFns to be an array, but got ${typeof visitFns}`); |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message uses template literal syntax but typeof on an array returns 'object', which isn't very helpful. Consider using Array.isArray() check result or providing the actual value type in a more descriptive way, e.g., Expected visitFns to be an array, but got ${visitFns === null ? 'null' : typeof visitFns}.
| throw new TypeError(`Expected visitFns to be an array, but got ${typeof visitFns}`); | |
| throw new TypeError(`Expected visitFns to be an array, but got ${visitFns === null ? 'null' : typeof visitFns}`); |
Prior to this change, certain JS Plugin failures would just point to Oxlint internals instead of the actual JS error.