Skip to content

implement SuppressedError builtin (ES2024, required for using / await using runtime semantics) #5314

@Nakshatra480

Description

@Nakshatra480

Summary

Boa is missing the SuppressedError builtin, which is part of the ECMAScript 2024
standard. This is a blocking gap for the Explicit Resource Management feature
(using / await using) - without it, the engine cannot correctly handle errors
that occur during resource disposal as required by the DisposeResources abstract
operation.


Current Behavior

Calling SuppressedError in Boa throws a ReferenceError because the constructor
does not exist:

new SuppressedError(new Error("dispose failed"), new Error("original"), "suppressed")
// ReferenceError: SuppressedError is not defined

Additionally, if a using block exits with an error and [Symbol.dispose]() also
throws, the engine has no mechanism to wrap both errors — the original error is
silently lost.


Expected Behavior

SuppressedError should be available as a global builtin that inherits from
Error.prototype, with the following constructor signature:

new SuppressedError(error, suppressed [, message])

And expose the following instance properties:

Property Description
.error The new error thrown during disposal
.suppressed The original error that was suppressed
.message Optional message string, defaults to ""
.name "SuppressedError"
.stack Inherited from Error.prototype

Acceptance Criteria

  • SuppressedError is available as a global constructor
  • new SuppressedError(error, suppressed, message) correctly sets .error,
    .suppressed, and .message properties
  • SuppressedError.prototype inherits from Error.prototype
  • SuppressedError.prototype.name is "SuppressedError"
  • new SuppressedError() instanceof Error returns true
  • new SuppressedError() instanceof SuppressedError returns true
  • A SuppressedError variant is added to JsNativeErrorKind so the VM can
    throw it natively from Rust-side disposal logic
  • All relevant test262 tests for SuppressedError pass

Implementation note: The closest reference in the codebase is AggregateError
in core/engine/src/builtins/error/aggregate.rs - SuppressedError should follow
the same pattern. Files to touch:

File Change
core/engine/src/builtins/error/suppressed.rs [new]
core/engine/src/builtins/error/mod.rs [modify] Register as native error
core/engine/src/context/intrinsics.rs [modify] Add to standard constructors
core/engine/src/error.rs [modify] Add SuppressedError to JsNativeErrorKind

Spec Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions