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 Clone Algorithm doesn't support FormData object #633

Closed
tevko opened this issue Feb 5, 2016 · 5 comments
Closed

Structured Clone Algorithm doesn't support FormData object #633

tevko opened this issue Feb 5, 2016 · 5 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: serialize and transfer

Comments

@tevko
Copy link

tevko commented Feb 5, 2016

ISSUE: When working with web-workers, it may be necessary to pass a FormData object to the worker via the postMessage method. Unfortunately, the Structured Clone Algorithm (used by the postMessage method to serialize the data being transferred) does not support FormData objects

Expected: postMessage method serializes FormData object and sends to worker

Actual: DATA_CLONE_ERR exception thrown on postMessage call

@foolip
Copy link
Member

foolip commented Feb 5, 2016

@domenic domenic added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Feb 5, 2016
@annevk
Copy link
Member

annevk commented Feb 8, 2016

@tevko we could do this I suppose (and it would be useful to define the specifics of fetch() and XMLHttpRequest). However, you can emulate this today through iteration and structured cloning the contents of what gets iterated. Is that not sufficient for your use case or is it just cumbersome?

@tevko
Copy link
Author

tevko commented Feb 8, 2016

@annevk that would be perfect, but I haven't been able to find anything that explains how I would successfully do that. Is there a resource anyone can point me to?

@annevk
Copy link
Member

annevk commented Feb 8, 2016

This works for me in Firefox (and should work per the specification, see https://xhr.spec.whatwg.org/#formdata):

 let fd = new FormData()
 fd.append("x", "y")
 fd.append("y", new Blob())
 for(let keyValue of fd)
   console.log(keyValue)

@annevk
Copy link
Member

annevk commented Mar 2, 2016

This is now whatwg/xhr#55.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: serialize and transfer
Development

No branches or pull requests

4 participants