Repository navigation
Closed
sass/sync-child-process
#38Description
Since Node 24.22.0, the synchronous API (initCompiler().compile()) fails on Linux x64 (glibc) with Compiler caused error: Invalid protobuf: ... when the compiled CSS is large. The async API (compileAsync) works fine on the same input. Node 24.21.0 and earlier work with both APIs.
node_modules/sass-embedded/dist/lib/src/compiler/sync.js:158
throw error;
^
Error: Compiler caused error: Invalid protobuf: Error: illegal tag: field no 13 wire type 6.
at compilerError (node_modules/sass-embedded/dist/lib/src/utils.js:91:12)
at decode (node_modules/sass-embedded/dist/lib/src/message-transformer.js:105:41)
at node_modules/rxjs/dist/cjs/internal/operators/map.js:10:37
...
Reproduction
repro.js:
const fs = require('fs');
const sass = require('sass-embedded');
// ~2.5 MB of CSS output
fs.writeFileSync('big.scss', Array.from({ length: 100000 }, (_, i) => .c${i} { color: red; }).join('\n'));
async function main() {
console.log(node ${process.version}, sass ${sass.info.replace(/\s+/g, ' ')});
for (let i = 1; i <= 5; i++) {
const compiler = sass.initCompiler();
try {
console.log(sync #${i}: ok, ${compiler.compile('big.scss').css.length} bytes);
} catch (e) {
console.log(sync #${i}: ${e.message.split('\n')[0]});
} finally {
compiler.dispose();
}
}
for (let i = 1; i <= 5; i++) {
try {
console.log(async #${i}: ok, ${(await sass.compileAsync('big.scss')).css.length} bytes);
} catch (e) {
console.log(async #${i}: ${e.message.split('\n')[0]});
}
}
}
main();Then run with:
docker run --rm -v "$PWD":/w -w /w node:24.22.0 \
bash -c 'npm i --silent --no-save [email protected] && node repro.js'Output size matters. Using generated files of the form .c0{color:red} .c1{color:red} ... with an increasing number of rules (5 sync compilations per size):
| Rules | Output size | Sync successes |
| ------- | ----------- | -------------- |
| 20,000 | ~500 KB | 5/5 |
| 30,000 | ~750 KB | 3/5 |
| 40,000 | ~1 MB | 1/5 |
| 60,000 | ~1.5 MB | 1/5 |
| 100,000 | ~2.5 MB | 0/5 |
Reacted by Dennis Tusk, Wellington Calor and Mateusz Górniak
Metadata
Metadata
Assignees
Labels
No labels
Activity
ntkme commentedon Oct 22, 2026
I'm getting slightly different result but this is reproducible: I'm seeing that both sync and async APIs are failing when output is very large.
Compiler caused error: Embedded compiler exited unexpectedly.Dispatcher closed before compilation completedI can reproduce it on linux (both glibc and musl-libc), but not on mac. I didn't get a chance to test windows.
Also, I can reproduce this compiler crash with ruby
sass-embeddedon linux, so that this is likely a problem on dart side, rather than on node side.ntkme commentedon Oct 22, 2026
After some digging what I noticed is that on my
podmanlinux VM where I was able to reproduce this, compiling a 9.7MB input is causing compiler to get OOM killed on the 2GB memory VM. The problem is the excessive memory usage in Dart VM.@Jealrock I see that the reproduction you provided is using
docker. Do you know how much memory your host os (if on linux) or docker linux vm (if on mac) or if the container has explicit memory limit?ntkme commentedon Oct 22, 2026
I tried it again and now I can reproduce
Compiler caused error: Invalid protobuf: Error: illegal tag: field no 13 wire type 6.error, and this appears to have a different root cause than OOM crash.ntkme commentedon Oct 23, 2026
I found the root cause: https://github.com/sass-contrib/sync-child-process/blob/ea3886972cca7e0b22515a4db0cbcffb5d47cd7a/lib/index.ts#L107
The
Buffer.from(message.data.buffer)sometimes returns a corrupted copy the buffer, and this is documented at https://nodejs.org/api/buffer.html#bufbuffer:I added a debug message as:
What I see is that
Buffer.from(message.data.buffer)is occasionally creating a copy that is not equal to originalmessage.data.ntkme commentedon Oct 23, 2026
I opened sass/sync-child-process#38 which should fix this bug.
Jealrock commentedon Oct 23, 2026
@ntkme thanks for quick response! I tried the suggested fix and it worked 🎉
fix(deps): override sync-child-process to 1.1.1