Sketch-sh / sketch-sh

Sketch.sh - Online Code Editor and ReasonML community
https://sketch.sh
Other
425 stars 37 forks source link

Recover from fatal error #242

Closed thangngoc89 closed 5 years ago

thangngoc89 commented 5 years ago

Even though I added catch error pretty much everywhere, the playground can't recover fatal errors.

Reproduce:

[%%bs.raw {|
  console.log(a);
|}]

It should produce a Type error. Now try to clean it and type in invalid code, it won't be executed.

mlms13 commented 5 years ago

I noticed this when I accidentally ran a non-tail-recursive endless function, along the lines of:

let rec recurse = xs => [0, ...recurse(xs)];

This pretty quickly blows the stack in the browser, but then deleting it and replacing with Js.log("a") doesn't produce any output.

thangngoc89 commented 5 years ago

@mlms13 yeah. i don't know the root cause of this but that sounds about right

thangngoc89 commented 5 years ago

Found it, here is the root cause:

https://github.com/frontarm/polestar/blob/d1201ee09b6e3988c98aeb9fddba55e267850583/src/Polestar.ts#L167-L169

I think we are supposed to create a new Polestar instance if error happened