webr icon indicating copy to clipboard operation
webr copied to clipboard

Some C-level errors break webR

Open wch opened this issue 6 months ago • 1 comments

We've found that some C-level errors cause webR to stop working correctly.

Here's an example:

install.packages("sass")
library(sass)

sass("
$primary-color: #333;
body {
  color: $primary-color;
}
")

# After this line in webR, the terminal will be unresponsive
sass("this will error")

In normal R, this is what shows:

> sass("this will error")
Error in compile_data(sass_input, options) : 
  Error: Invalid CSS after "this will error": expected "{", was ""
        on line 1:16 of stdin
>> this will error
   ---------------^

If it's run in https://webr.r-wasm.org/latest/, then the terminal freezes. There is also an uncaught error in the JS console.

Image

For reference, this is the compile_data() C function: https://github.com/rstudio/sass/blob/d9fe9716de08384797a82f9db945587c0243a35d/src/compile.c#L113-L140

cc @gadenbuie

wch avatar Apr 09 '25 18:04 wch