Skip to content

Playground: Add ability to stop a running script #2541

Closed

Description

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.

image

Repro:

  1. Simply run the following line of code in the playground, and run the code.
let interval = setInterval(() => { console.log('A') }, 1000);
  1. 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.

Activity

  1. orta commented on Sep 30, 2022

    @orta
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    PlaygroundIssues that affect the Playground

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions