fix(css): retry scss compilation when the embedded sass compiler fails to spawn - #23375
Open
lopno wants to merge 1 commit into
Open
fix(css): retry scss compilation when the embedded sass compiler fails to spawn#23375lopno wants to merge 1 commit into
lopno wants to merge 1 commit into
Conversation
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.
Description
Fixes #23374. Related: #20825 (closed, locked).
When
sass-embedded's compiler child process fails to spawn (e.g. intermittentspawn EBADFon macOS under fd pressure), the scss worker currently caches the dead compiler forever:initAsyncCompiler()resolves before the spawn settles, so the failure only surfaces per-compileStringAsynccall, andcompilerPromise ??=never re-runs. One lost race means every scss compile fails until the dev server is restarted.This change retries once: if a compile rejects with a process-spawn error (
err.syscallstarting withspawn— real sass errors don't have it and are rethrown unchanged), the cached compiler is dropped and disposed fire-and-forget, and the compile runs again against a freshly spawned process.Alternatives considered: retrying inside
initAsyncCompilerisn't possible from Vite's side (it never rejects), and resetting only instop()doesn't help a long-lived server. Scoping the retry tosyscall: 'spawn*'errors keeps deliberate failures (bad scss, missing files) untouched.Tests: not included — exercising this requires making
sass-embedded's internalchild_process.spawnfail once, and neithermakeScssWorkernor a spawn seam is exported. I validated the equivalent retry logic against a stubbed compiler externally (single shared respawn under concurrent failures, sass errors pass through with zero retries), pluspnpm -F vite build,typecheck, and the css unit tests. Happy to add a test if you can suggest a seam you'd accept.AI disclosure (per the AI policy): this fix was developed with AI assistance under my direction, including the root-cause investigation (module-resolution traces and reproduction of the EBADF cascade against a large app). I reviewed the final diff line by line; the retry scoping (
syscallgate, single retry, fire-and-forget dispose of the dead compiler) reflects deliberate choices to keep the change minimal and never mask real compile errors.