VSCode: Fix ENOENT causing file to be emptied when StyLua binary is missing#1116
Merged
Merged
Conversation
The child process error event was registered as "err" instead of the correct "error", so spawn failures (e.g. ENOENT when the binary does not exist) were never caught. The stdout close handler would then resolve the Promise with an empty string, causing the extension to replace the entire document with empty content. Fixes #1001 https://claude.ai/code/session_01QdJCgv72HVtH1ryEkJwLoM
Verifies that formatCode rejects (rather than resolves with an empty string) when the StyLua binary path does not exist. https://claude.ai/code/session_01QdJCgv72HVtH1ryEkJwLoM
- Replace didResolve flag in test with assert.rejects - Suppress unhandled EPIPE on child.stdin when spawn fails - Fix executeStylua: add return after reject so resolve doesn't also run - Remove self-evident comment on stdin.write - Resolve CHANGELOG merge conflict with main https://claude.ai/code/session_01QdJCgv72HVtH1ryEkJwLoM
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1116 +/- ##
=======================================
Coverage 96.66% 96.66%
=======================================
Files 16 16
Lines 5307 5307
=======================================
Hits 5130 5130
Misses 177 177 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
The child process error event was registered as "err" instead of the
correct "error", so spawn failures (e.g. ENOENT when the binary does
not exist) were never caught. The stdout close handler would then
resolve the Promise with an empty string, causing the extension to
replace the entire document with empty content.
Fixes #1001