Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

JS API for traps #89

Closed
Closed
@aheejin

Description

@aheejin

I proposed not to catch traps with wasm catch instruction in #1 (comment). Even though it has not been decided yet, in this issue I'd like to discuss JS API changes in case we decide not to catch traps as I proposed.

To make this behavior consistent, traps should not be catchable both before and after they hit a JS frame. To this end, it might be convenient if we have JS API to create a WebAssembly trap, like

trap = new WebAssembly.Trap()

So that we can maintain its trap identity in both JS and wasm.

But the current JS API specifies if an exported function call traps, the JS frame that called the exported function should throw a WebAssembly.RuntimeError.

So I'm wondering, should we preserve this behavior? If we should, we may have to make catch not catch RuntimeError exception. RuntimeError contains various error conditions other than traps. I think most cases of RuntimeError are unrecoverable errors, but would there be any case of non-trap RuntimeError that should be caught by catch instruction?

Or, would it be better to create WebAssembly.Trap and change the JS API so that in case of a wasm trap, its embedding JS frame throws not RuntimeError but Trap instead, and catch instruction catches all other JS exceptions except for Trap?

cc @dschuff @mstarzinger @Ms2ger @lukewagner @rossberg
@backes (In case this has implementation issues)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions