Skip to content

src: support (de)serialization of DOMException #57372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

jazelly
Copy link
Member

@jazelly jazelly commented Mar 8, 2025

Added serialization and deserialization support for DOMException. Ideally we shouldn't do this in native, but since it's compiled before an Environment exists, we cannot mark it as kCloneable and provide associated serialization methods in JS land.

Fixes: #49181

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Mar 8, 2025
@jazelly jazelly force-pushed the serialize-dom-exception branch 2 times, most recently from c73bc7f to b039fee Compare March 8, 2025 03:12
Copy link

codecov bot commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 26.82927% with 90 lines in your changes missing coverage. Please review.

Project coverage is 90.10%. Comparing base (3a497dc) to head (ee1dacf).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/node_messaging.cc 26.82% 83 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57372      +/-   ##
==========================================
- Coverage   90.22%   90.10%   -0.12%     
==========================================
  Files         630      630              
  Lines      185259   185332      +73     
  Branches    36245    36247       +2     
==========================================
- Hits       167143   166998     -145     
- Misses      11063    11285     +222     
+ Partials     7053     7049       -4     
Files with missing lines Coverage Δ
src/node_messaging.cc 77.59% <26.82%> (-5.88%) ⬇️

... and 46 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jazelly jazelly force-pushed the serialize-dom-exception branch 2 times, most recently from 0aec3cf to 96f824c Compare March 8, 2025 08:42
@jazelly jazelly requested review from legendecas and addaleax March 9, 2025 07:34
@jazelly jazelly added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 9, 2025
@jazelly jazelly requested a review from joyeecheung March 9, 2025 21:21
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 9, 2025
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Private symbols are per-isolate data and initialized before an Environment is created (in IsolateData). It does not depend on an Environment. Yet, it needs a bit of refactor on the NewContext and GetPerContextExports so that InitializePrimordials can access the private symbols.

@jazelly jazelly force-pushed the serialize-dom-exception branch from 947742c to ee1dacf Compare March 10, 2025 13:12
@jazelly jazelly marked this pull request as draft March 10, 2025 13:20
@jazelly
Copy link
Member Author

jazelly commented Mar 11, 2025

Yet, it needs a bit of refactor on the NewContext and GetPerContextExports so that InitializePrimordials can access the private symbols

IIUC, we need to pass isolate_data into these so that we can get private symbols and other symbols without env

@jazelly jazelly force-pushed the serialize-dom-exception branch from 440dcd7 to cded81b Compare March 14, 2025 12:08
@@ -52,6 +55,8 @@ class DOMException {
constructor(message = '', options = 'Error') {
ErrorCaptureStackTrace(this);

this[is_dom_exception] = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe use class property syntax to set this using [[Define]] semantics?

class DOMException {
	[is_dom_exception] = true;

	constructor(message = '', options = 'Error') {
		...
	}
}

@jazelly jazelly force-pushed the serialize-dom-exception branch from cded81b to 2ec57d7 Compare March 15, 2025 06:02
@jazelly
Copy link
Member Author

jazelly commented Mar 15, 2025

Opened #57479 to help tackle this. That one, as the first step, works fine, but I need a bit of time working on this, as with current manual (de)serialize approach there is a stackTrace problem when posting DOMException to worker. I will try

  1. expose symbols as well so that we can use the combination of tranfer_mode_private_symbol + kClone + kDeserialize
  2. figure out why stackTrace cannot be inferred by V8 in worker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stucturedClone defective for DataCloneError
5 participants