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

Structured cloning of errors makes invalid assumptions about [[GetPrototypeOf]] #4991

Closed
bzbarsky opened this issue Oct 8, 2019 · 7 comments
Labels
clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project topic: serialize and transfer

Comments

@bzbarsky
Copy link
Contributor

bzbarsky commented Oct 8, 2019

https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal step 17 (the [[ErrorData]] case) substep 2 does:

Let valueProto be ! value.[GetPrototypeOf].

But [[GetPrototypeOf]] can in fact return an abrupt completion, so this step can't use !. Does it mean to use ? or do something else? Are there tests for the throwing case here?

@yutakahirano @TimothyGu @domenic

@yutakahirano
Copy link
Member

value has an [[ErrorData]] internal slot, so it is an ordinary object and [[GetPrototypeOf]] never throws. Should we use OrdinaryGetPrototypeOf?

@bzbarsky
Copy link
Contributor Author

bzbarsky commented Oct 9, 2019

Ah, I see. That might be clearer, yes.

@domenic
Copy link
Member

domenic commented Oct 9, 2019

I prefer not bypassing the [[ methods, so instead I guess we could add a note explaining the assert.

@bzbarsky
Copy link
Contributor Author

bzbarsky commented Oct 9, 2019

That would be fine too, thank you.

@annevk annevk added clarification Standard could be clearer topic: serialize and transfer good first issue Ideal for someone new to a WHATWG standard or software project labels Oct 9, 2019
@annevk
Copy link
Member

annevk commented Oct 9, 2019

The fix here would be adding something like "value is an ordinary object due to its [[ErrorData]] internal slot." as a note below the text quoted in OP.

@TimothyGu
Copy link
Member

I don't think an implementation is necessarily disallowed from creating an exotic object with [[ErrorData]] internal slot. I'd suggest the following fix:

-if value has an [[ErrorData]] internal slot and value is not a platform object, then:
+if value is an ordinary object, has an [[ErrorData]] internal slot, and is not a platform object, then:

@domenic
Copy link
Member

domenic commented Apr 23, 2020

This is obsolete now that #5150 is merged. We could open a new issue/PR for the issue @TimothyGu raised, but that would be a separate normative change (of not structured-cloning exotic objects with an [[ErrorData]] internal slot), and a rather theoretical one.

@domenic domenic closed this as completed Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project topic: serialize and transfer
Development

No branches or pull requests

5 participants