Skip to content

HTML integration for "Error Stack Accessor" TC39 Proposal - #12239

Merged
annevk merged 2 commits into
whatwg:mainfrom
ljharb:error-stack-accessor-integration
May 26, 2026
Merged

annevk merged 2 commits into
whatwg:mainfrom
ljharb:error-stack-accessor-integration

Conversation

@ljharb

@ljharb ljharb commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

Replace the non-normative "should" language about serializing "interesting accompanying data" with normative steps that explicitly serialize and deserialize the stack trace of Error objects during structured cloning.

In StructuredSerializeInternal, the stack trace is obtained as an implementation-defined string and included in the serialized record as [[Stack]].

In StructuredDeserialize, the Error object is created with a [[Stack]] internal slot, which is set to an implementation-defined value representing the stack trace from the serialized record. This ensures the Error.prototype.stack accessor continues to work properly on deserialized errors.

The bibliography is updated to reference both the Error Stack Accessor and Error Stacks proposals.

This is the HTML integration PR for tc39/proposal-error-stack-accessor.

See tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8, as well as whatwg/webidl#1578

(See WHATWG Working Mode: Changes for more details.)


/references.html ( diff )
/structured-data.html ( diff )

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is other "interesting data" that should still be copied over, such as https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber.

Comment thread source Outdated
@annevk annevk added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: serialize and transfer labels Mar 10, 2026
@ljharb

ljharb commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@nicolo-ribaudo should that be called out, or left implementation-defined?

@ljharb
ljharb force-pushed the error-stack-accessor-integration branch from a426672 to 9f15d18 Compare March 11, 2026 15:33
@nicolo-ribaudo

nicolo-ribaudo commented Mar 11, 2026 •

Copy link
Copy Markdown
Member

The old spec text was:

User agents should attach a serialized representation of any interesting accompanying data which are not yet specified, notably the stack property, to serialized.

You replaced it with explicit steps to copy stack, but I think you should also keep including

User agents should attach a serialized representation of any interesting accompanying data which are not yet specified to serialized.

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah, let's preserve the "interesting accompanying data" step as well. Hopefully one day that won't be needed anymore.

Comment thread source Outdated
Comment thread source Outdated
@ljharb
ljharb force-pushed the error-stack-accessor-integration branch 2 times, most recently from 9f12aa1 to 72af89f Compare May 6, 2026 16:57
Comment thread source Outdated
Comment thread source
@ljharb
ljharb force-pushed the error-stack-accessor-integration branch from 72af89f to ed48b89 Compare May 8, 2026 16:44
Comment thread source Outdated
Comment thread source
ljharb added 2 commits May 19, 2026 10:33
Replace the non-normative "should" language about serializing "interesting accompanying data" with normative steps that explicitly serialize and deserialize the stack trace of Error objects during structured cloning.

In StructuredSerializeInternal, the stack trace is obtained as an implementation-defined string and included in the serialized record as [[Stack]].

In StructuredDeserialize, the Error object is created with a [[Stack]] internal slot, which is set to an implementation-defined value representing the stack trace from the serialized record.
This ensures the Error.prototype.stack accessor continues to work properly on deserialized errors.

The bibliography is updated to reference both the Error Stack Accessor and Error Stacks proposals.

This is the HTML integration PR for tc39/proposal-error-stack-accessor.

See tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8
- Access value.[[Stack]] in serialization (annevk)
- Reorder: Set serialized before User agents should... step
- Drop "notably the stack property" example from interesting
  accompanying data step (now explicit) (annevk)
- Simplify deserialize: pass serialized.[[Stack]] through as-is
  rather than re-wrapping as implementation-defined (annevk)
@ljharb
ljharb force-pushed the error-stack-accessor-integration branch from ed48b89 to 0b68000 Compare May 19, 2026 08:43

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good now. I guess now we have to wait for these proposals to reach stage 2.7-3.

@ljharb

ljharb commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

The proposal is now stage 3, and test262 tests for it have been merged.

annevk pushed a commit to web-platform-tests/wpt that referenced this pull request May 26, 2026
…ion (#58397)

Add tests for DOMException .stack behavior per the TC39 Error Stack
Accessor proposal (https://tc39.es/proposal-error-stack-accessor/) and
HTML (whatwg/html#12239) & Web IDL
(whatwg/webidl#1421) integration:

- DOMException instances get .stack as a string via Error.prototype.stack accessor
- Error.prototype.stack property descriptor has correct accessor attributes
- Error.prototype.stack getter works on DOMException instances
- Error.prototype.stack setter (SetterThatIgnoresPrototypeProperties) behavior
- DOMException.prototype does not have an own stack property

Add tests for structured clone serialization/deserialization of [[Stack]]:

- structuredClone() preserves .stack on Error and all NativeError subtypes
- structuredClone() preserves .stack on DOMException (constructed and thrown)
- Cloned .stack is accessed via the accessor, not as an own property

See also tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8.
annevk pushed a commit to whatwg/webidl that referenced this pull request May 26, 2026
Since DOMException objects have [[ErrorData]], the Error.prototype.stack accessor from the Error Stack Accessor proposal applies to them.

Tests: web-platform-tests/wpt#58397.

Corresponding HTML PR: whatwg/html#12239.

See also tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8.
@annevk
annevk merged commit 9b5f1b3 into whatwg:main May 26, 2026
2 of 3 checks passed
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request May 29, 2026
…roposal web platform integration, a=testonly

Automatic update from web-platform-tests
Add WPT tests for Error Stack Accessor proposal web platform integration (#58397)

Add tests for DOMException .stack behavior per the TC39 Error Stack
Accessor proposal (https://tc39.es/proposal-error-stack-accessor/) and
HTML (whatwg/html#12239) & Web IDL
(whatwg/webidl#1421) integration:

- DOMException instances get .stack as a string via Error.prototype.stack accessor
- Error.prototype.stack property descriptor has correct accessor attributes
- Error.prototype.stack getter works on DOMException instances
- Error.prototype.stack setter (SetterThatIgnoresPrototypeProperties) behavior
- DOMException.prototype does not have an own stack property

Add tests for structured clone serialization/deserialization of [[Stack]]:

- structuredClone() preserves .stack on Error and all NativeError subtypes
- structuredClone() preserves .stack on DOMException (constructed and thrown)
- Cloned .stack is accessed via the accessor, not as an own property

See also tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8.
--

wpt-commits: a6fd2ac12d6662adafc266a4431c8cbdf1eb0195
wpt-pr: 58397
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jun 1, 2026
…roposal web platform integration, a=testonly

Automatic update from web-platform-tests
Add WPT tests for Error Stack Accessor proposal web platform integration (#58397)

Add tests for DOMException .stack behavior per the TC39 Error Stack
Accessor proposal (https://tc39.es/proposal-error-stack-accessor/) and
HTML (whatwg/html#12239) & Web IDL
(whatwg/webidl#1421) integration:

- DOMException instances get .stack as a string via Error.prototype.stack accessor
- Error.prototype.stack property descriptor has correct accessor attributes
- Error.prototype.stack getter works on DOMException instances
- Error.prototype.stack setter (SetterThatIgnoresPrototypeProperties) behavior
- DOMException.prototype does not have an own stack property

Add tests for structured clone serialization/deserialization of [[Stack]]:

- structuredClone() preserves .stack on Error and all NativeError subtypes
- structuredClone() preserves .stack on DOMException (constructed and thrown)
- Cloned .stack is accessed via the accessor, not as an own property

See also tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8.
--

wpt-commits: a6fd2ac12d6662adafc266a4431c8cbdf1eb0195
wpt-pr: 58397

UltraBlame original commit: 7c5705517993438019c649bc426e1cb442656635
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jun 1, 2026
…roposal web platform integration, a=testonly

Automatic update from web-platform-tests
Add WPT tests for Error Stack Accessor proposal web platform integration (#58397)

Add tests for DOMException .stack behavior per the TC39 Error Stack
Accessor proposal (https://tc39.es/proposal-error-stack-accessor/) and
HTML (whatwg/html#12239) & Web IDL
(whatwg/webidl#1421) integration:

- DOMException instances get .stack as a string via Error.prototype.stack accessor
- Error.prototype.stack property descriptor has correct accessor attributes
- Error.prototype.stack getter works on DOMException instances
- Error.prototype.stack setter (SetterThatIgnoresPrototypeProperties) behavior
- DOMException.prototype does not have an own stack property

Add tests for structured clone serialization/deserialization of [[Stack]]:

- structuredClone() preserves .stack on Error and all NativeError subtypes
- structuredClone() preserves .stack on DOMException (constructed and thrown)
- Cloned .stack is accessed via the accessor, not as an own property

See also tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8.
--

wpt-commits: a6fd2ac12d6662adafc266a4431c8cbdf1eb0195
wpt-pr: 58397

UltraBlame original commit: 7c5705517993438019c649bc426e1cb442656635
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jun 1, 2026
…roposal web platform integration, a=testonly

Automatic update from web-platform-tests
Add WPT tests for Error Stack Accessor proposal web platform integration (#58397)

Add tests for DOMException .stack behavior per the TC39 Error Stack
Accessor proposal (https://tc39.es/proposal-error-stack-accessor/) and
HTML (whatwg/html#12239) & Web IDL
(whatwg/webidl#1421) integration:

- DOMException instances get .stack as a string via Error.prototype.stack accessor
- Error.prototype.stack property descriptor has correct accessor attributes
- Error.prototype.stack getter works on DOMException instances
- Error.prototype.stack setter (SetterThatIgnoresPrototypeProperties) behavior
- DOMException.prototype does not have an own stack property

Add tests for structured clone serialization/deserialization of [[Stack]]:

- structuredClone() preserves .stack on Error and all NativeError subtypes
- structuredClone() preserves .stack on DOMException (constructed and thrown)
- Cloned .stack is accessed via the accessor, not as an own property

See also tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8.
--

wpt-commits: a6fd2ac12d6662adafc266a4431c8cbdf1eb0195
wpt-pr: 58397

UltraBlame original commit: 7c5705517993438019c649bc426e1cb442656635
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…roposal web platform integration, a=testonly

Automatic update from web-platform-tests
Add WPT tests for Error Stack Accessor proposal web platform integration (#58397)

Add tests for DOMException .stack behavior per the TC39 Error Stack
Accessor proposal (https://tc39.es/proposal-error-stack-accessor/) and
HTML (whatwg/html#12239) & Web IDL
(whatwg/webidl#1421) integration:

- DOMException instances get .stack as a string via Error.prototype.stack accessor
- Error.prototype.stack property descriptor has correct accessor attributes
- Error.prototype.stack getter works on DOMException instances
- Error.prototype.stack setter (SetterThatIgnoresPrototypeProperties) behavior
- DOMException.prototype does not have an own stack property

Add tests for structured clone serialization/deserialization of [[Stack]]:

- structuredClone() preserves .stack on Error and all NativeError subtypes
- structuredClone() preserves .stack on DOMException (constructed and thrown)
- Cloned .stack is accessed via the accessor, not as an own property

See also tc39/proposal-error-stack-accessor#9 and tc39/proposal-error-stack-accessor#8.
--

wpt-commits: a6fd2ac12d6662adafc266a4431c8cbdf1eb0195
wpt-pr: 58397
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: serialize and transfer

Development

Successfully merging this pull request may close these issues.

3 participants