-
Notifications
You must be signed in to change notification settings - Fork 312
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
Client.postMessage() throwing for unloaded client is problematic #1291
Comments
cc @jungkees |
I see. @jakearchibald, do you recall anything about it? From web-platform-tests/wpt#10153 (comment),
When @mattto approved #1274, I thought we could maintain a data structure in the browser process that tracks the clients. |
I didn't realize postMessage usually doesn't throw. Sounds like we should just drop the message silently then. |
Would this be trying to get the destination and returning if the target doesn't exist? Or just queuing a task for the event and the task failing to find a target in the content process? I think Do you expect we have a similar behavior for |
It sounds like postMessage should just be best-effort and if the message couldn't be delivered, regardless of the reason, it just fails silently. |
I don't think this is relevant to the current bug thread, but I wanted to point out that that is not quite the general principle these days. In particular messages that cannot be delivered because of deserialization errors (such as crossing process boundaries while passing a SharedArrayBuffer) are currently specced to generate a messageerror event at the destination. (We talked a bit about signaling back to the source, but that's tricky, and the whole discussion was light on use cases, so it was deferred.) Just something to remember when talking about the model of how postMessage deals with errors. |
Sure, the list is maintained in the browser process, but accessing that list from the renderer process is going to be async. Unless we want to block or spin the event loop while we consult cross-process state we can't synchronously throw here. IMO anyway. |
@domenic, thanks for the information. Good to be aware of for future discussion.
Ah.. right. This call starts from the renderer. I was confused myself we were on the browser process at the beginning. I'll make another PR to address this issue and close the PR in WPT. I'm thinking of getting the associated service worker client and returning if it doesn't exist, which would be analogous to https://cs.chromium.org/chromium/src/content/browser/service_worker/service_worker_version.cc?type=cs&q=ServiceWorkerVersion::PostMessageToClient&l=1155. |
cf834f0 clarified the target object can be null, and it must throw in that case. But #1291 pointed out that we cannot implement that behavior without blocking the service worker process in multi-process browser architectures. This change makes the control return right away if the target client has been unloaded. Fixes #1291.
cf834f0 clarified the target object can be null, and it must throw in that case. But #1291 pointed out that we cannot implement that behavior without blocking the service worker process in multi-process browser architectures. This change makes the control return right away if the target client has been unloaded. Fixes #1291.
Currently
Client.postMessage()
says:This is problematic for a few reasons:
postMessage()
implementations don't throw. They just silently consume the message if the other end is no longer listening. For example Worker.postMessage() and MessageChannel, etc.If we wanted we could change postMessage() to return a promise, but its probably better to just silently eat the message.
I'm filing this issue in regards to web-platform-tests/wpt#10153
The text was updated successfully, but these errors were encountered: