Skip to content

feat(wintertc): implement structured clone for DataView - #5529

Closed
MayankSharma-2812 wants to merge 1 commit into
boa-dev:mainfrom
MayankSharma-2812:fix/structured-clone-dataview
Closed

MayankSharma-2812 wants to merge 1 commit into
boa-dev:mainfrom
MayankSharma-2812:fix/structured-clone-dataview

Conversation

@MayankSharma-2812

@MayankSharma-2812 MayankSharma-2812 commented Sep 16, 2026 •

Copy link
Copy Markdown

Describe the bug

Calling structuredClone() on a DataView instance currently throws TypeError: Data views are not supported yet. instead of returning a cloned DataView.

To Reproduce

const buffer = new ArrayBuffer(16);
const view = new DataView(buffer, 4, 8);
view.setInt32(0, 42);

const copy = structuredClone(view);
// Throws: TypeError: Data views are not supported yet.

Expected behavior
Per the [WHATWG HTML Structured Clone algorithm](https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal), DataView is a supported cloneable platform object (§2.7.2 Transferable Objects and Platform Objects).

Running this code, structuredClone(view) should return a new DataView instance wrapping a clone of the underlying ArrayBuffer, preserving byteOffset (4) and byteLength (8). Mutating the original view should not affect the clone.

Build environment
OS: Windows 11
Target triple: x86_64-pc-windows-msvc
Rustc version: rustc 1.96.0
Additional context
In core/wintertc/src/store/from.rs:
} else if let Ok(_dataview) = JsDataView::from_object(object.clone()) {
    return Err(js_error!(TypeError: "Data views are not supported yet."));
}
The deserialization logic (try_into_data_view in to.rs) and storage enum variant (ValueStoreInner::DataView in mod.rs) are already implemented; only the serialization function clone_data_view in from.rs was missing.

More information: [MDN Structured Clone Algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types).

@MayankSharma-2812
MayankSharma-2812 requested a review from a team as a code owner September 16, 2026 09:09
@github-actions github-actions Bot added Waiting On Review Waiting on reviews from the maintainers C-Tests Issues and PRs related to the tests. and removed Waiting On Review Waiting on reviews from the maintainers labels Sep 16, 2026
@github-actions github-actions Bot added this to the v0.23 milestone Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant