You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Playground: Add ability to stop a running script #2541
When running some code in the playground, there is no way to stop the execution of a running program (a la Ctrl+C in the terminal). This can lead to some weird behaviour. For example, set an interval to log A to the console periodically and run the code. Changing the output to B causes A and B to both be output to the console.
Repro:
Simply run the following line of code in the playground, and run the code.
let interval = setInterval(() => { console.log('A') }, 1000);
Modify the code, and 'run' again:
let interval = setInterval(() => { console.log('B') }, 1000);
Expected behavior:
I expect only 'B' to be printed. Actual behavior:
'B' and 'A' are being printed.
This is kind of the halting problem, but I dont think there's a way in the JS runtime to eval your code and be able to stop all side-effects like your setInterval from being ran. This is not really feasible without shadowrealms I expect and that brings with it a whole host of other issues which make this not really doable.
Activity
orta commentedon Sep 30, 2022
This is kind of the halting problem, but I dont think there's a way in the JS runtime to eval your code and be able to stop all side-effects like your setInterval from being ran. This is not really feasible without shadowrealms I expect and that brings with it a whole host of other issues which make this not really doable.