Closed hi-ogawa closed 1 day ago
I forgot to check past issues and just noticed that this is probably a duplicate of https://github.com/sass/dart-sass/issues/1243.
I raised an issue here as I thought it's a bit odd that one is stack overflow and the other is heap OOM, but I guess it's an error either way, so not sure if this is really a bug. Feel free to triage as you see fit.
This is working as expected - infinite recursion will cause stack overflow or out of memory, which is expected in any programming language. The reason that you are seeing different errors is that dart runtime and node runtime have different stack limit and memory limit, whichever runs out first would throw an error.
On the other hand, it is possible to run static analysis and perhaps warn about any possible unconditional recursion, but that probably out of scope for now.
We could manually track the stack length to try to consistently throw a stack overflow error, but that would also unavoidably put a harder limit on legitimate recursion than the underlying machine can support, which isn't necessarily a good thing. I think leaving this as-is is best. Sass is a programming language, and if you make it loop infinitely it's going to fail.
This is originally reported on Vite https://github.com/vitejs/vite/issues/18091 and I made a minimal reproduction here https://github.com/hi-ogawa/reproductions/tree/main/vite-18091-sass-recurrence-oom
For the following code,
sass-embedded
gets toInternal compiler error: Stack Overflow
quickly whilesass
package causes heap OOM.