Skip to content
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

Transfer should not be null or undefined in structuredClone #55280

Open
jazelly opened this issue Oct 5, 2024 · 1 comment
Open

Transfer should not be null or undefined in structuredClone #55280

jazelly opened this issue Oct 5, 2024 · 1 comment
Labels
web-standards Issues and PRs related to Web APIs

Comments

@jazelly
Copy link
Contributor

jazelly commented Oct 5, 2024

Version

22.9.0

Platform

N/A

Subsystem

No response

What steps will reproduce the bug?

// transfer should not be null
structuredClone(undefined, { transfer: null });

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

It should throw TypeError like other runtimes.

What do you see instead?

it passed

Additional information

I didn't find any requirements on type checking, but seems like other runtimes unanimously perform the webidl sequence conversion for transfer. IMO, we should do the same.

There are two ways to do this.

One is quick win by updating the check here

if (transfer_list_v->IsNullOrUndefined()) {

The other one is to perform WebIDL conversion at JS layer before hitting the native StructuredClone. I understand the current implementation has been completely moved to cc, so I am not sure if that approach would be more preferable, but it does benefit us from reducing the C++ to JS overhead inside this function

if (!ReadIterable(env, context, *transfer_list_out, transfer_list_v)

@RedYetiDev RedYetiDev added the web-standards Issues and PRs related to Web APIs label Oct 5, 2024
@jazelly
Copy link
Contributor Author

jazelly commented Oct 6, 2024

FWIW, on chrome or deno, you can see their attempt to webidl conversion. Here is the output from chrome

VM468:1 Uncaught TypeError: Failed to execute 'structuredClone' on 'Window': Failed to read the 'transfer' property from 'StructuredSerializeOptions': The provided value cannot be converted to a sequence.
    at <anonymous>:1:1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-standards Issues and PRs related to Web APIs
Projects
None yet
Development

No branches or pull requests

2 participants