Skip to content

Transfer should not be null or undefined in structuredClone #55280

Description

@jazelly

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)

Activity

  1. added
    web-standardsIssues and PRs related to web-platform APIs and standards compliance.
    on Oct 5, 2024
  2. jazelly commented on Oct 6, 2024

    @jazelly
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    web-standardsIssues and PRs related to web-platform APIs and standards compliance.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions