WebAssembly / WebAssembly/custom-descriptors

Wasm exception objects and debuggers

Open
#80 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
12
Forks
3
Avg merge
3d 2h
Merged PRs (30d)
1

Description

To do some follow-up on #76, specifically about the case of Wasm exception objects and how they behave wrt. debuggers.

In Munich, we discussed this issue IIRC with @lukewagner and @aheejin (if I made the right GitHub handle connections). One possible solution came up that would build on Custom Descriptors: a standardized well-known symbol that redirects to a "real" JS Error instance.

Currently, exception objects like java.lang.Throwable are Wasm objects, so they cannot extend the JS Error class, and do not get stack trace information. However, we make them contain, in a field, a reference to a freshly allocated Error instance. This allows to implement things like Throwable.getStackTrace() by inspecting the underlyingJSError.stack property. So we're not completely clueless: internal language tools, testing frameworks, etc., understand the stack traces.

What we're missing is for debuggers to understand our exception objects. A possible solution would be to use Custom Descriptors to expose the underlying Error instance in a standardized way, which debuggers could access:

  • Define a well-known symbol WebAssembly.underlyingError
  • Register a get [WebAssembly.underlyingError]() on the JS prototype associated to java.lang.Throwable
  • Have its body return the Error instance that we are storing inside our exception objects.

Now, debuggers can use that information. If they hold a thing e that's not an "error object", they can try to look into e[WebAssembly.underlyingError] to get a second chance. They could then offer all the nice debugging infrastructure for Wasm objects, based on that underlying Error instance.

Arguably, such a proposal could go all the way up to TC39 as Symbol.underlyingError rather than WebAssembly.underlyingError.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review follow-up issue #76 and the Custom Descriptors discussion, including the proposed WebAssembly.underlyingError and Symbol.underlyingError alternatives. Establish the debugger-facing behavior and proposal scope; done requires an agreed direction, since no implementation files or tests are identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, wasm
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.