Skip to content

Allow script aborting? #401

Open
Open

Description

Right now multiple environments provide the abiltiy to abort a script mid-run, which the spec does not allow. For example, Node.js's vm module allows timeouts on script execution, and its process.abort() and process.exit() functions can interrupt script execution from inside script.

HTML has a whole section on this, as aborting scripts happens fairly often: the infamous "slow script dialog", but also e.g. page navigation, closing a window, or disabling JavaScript in the browser (these days through extensions) mid-run. And, perhaps most explicitly, the worker.terminate() method.

In whatwg/html@6a48bfb we made this a little more formal by noting exactly what this impacts and where it is called: go to https://html.spec.whatwg.org/#abort-a-running-script, click the words "abort a running script", and you can see all callers and referencers. We added the statement:

Although the JavaScript specification does not account for this possibility, it's sometimes necessary to abort a running script. This causes any ScriptEvaluation or ModuleEvaluation to cease immediately, emptying the JavaScript execution context stack without triggering any of the normal mechanisms like finally blocks. [ECMA262]

It's probably a good idea for ES to explicitly mention this possibility in its spec, and maybe make it more formal. What do you think?

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

Metadata

Assignees

No one assigned

    Labels

    normative changeAffects behavior required to correctly evaluate some ECMAScript source text

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions