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

ServiceWorker.postMessage() references the not-yet-created worker global #1126

Closed
jungkees opened this issue Apr 19, 2017 · 3 comments
Closed
Milestone

Comments

@jungkees
Copy link
Collaborator

Raised by #1102 (comment).

We call "Run Service Worker", which in parallel creates the workers global object, yet postMessage in the next step tries to synchronously access that global (which hasn't been created yet at that point). It seems instead postMessage should synchronously serialize the message, and then queue a task on the worker to actually deliver the message event after the worker has started up?

@jungkees
Copy link
Collaborator Author

I think we need the global object to get the target realm to invoke StructuredCloneWithTransfer(message, transfer, targetRealm). This serialization should be done on the calling context, right? Or does it make sense to run StructuredCloneWithTransfer() in the queued task?

@domenic
Copy link
Contributor

domenic commented Apr 19, 2017

I think the idea is that you stop using StructuredCloneWithTransfer() entirely, and instead use separate StructuredSerializeWithTransfer/StructuredDeserializeWithTransfer steps. Maybe I can work that out in a new PR.

@jungkees
Copy link
Collaborator Author

use separate StructuredSerializeWithTransfer/StructuredDeserializeWithTransfer steps.

I see. That makes sense.

Maybe I can work that out in a new PR.

I'd appreciate it.

domenic added a commit to domenic/ServiceWorker that referenced this issue Apr 20, 2017
Fixes w3c#1089 by updating to the latest in structured serialize/deserialize technology, and fixes w3c#1126 by properly deserializing in the queued task instead of ahead of time.
domenic added a commit to domenic/ServiceWorker that referenced this issue Apr 20, 2017
Fixes w3c#1089 by updating to the latest in structured serialize/deserialize technology, and fixes w3c#1126 by properly deserializing in the queued task instead of ahead of time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants