Messages sent to workers can be lost when the worker closes
Categories
(DevTools :: Debugger, defect, P2)
Tracking
(firefox70 fixed)
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: bhackett1024, Assigned: bhackett1024)
References
(Blocks 1 open bug)
Details
(Whiteboard: [debugger-mvp])
Attachments
(2 files)
2.22 KB,
patch
|
Details | Diff | Splinter Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
Recent breakpoint changes seem to have exposed a problem with the protocol used when communicating with a worker thread. The series of steps is as follows:
- The client sends a request to an actor associated with a worker.
- This request goes through the normal procedure for communicating with the worker, ending with the this._dbg.postMessage() call in worker-transport.js
- Before the worker can send a response to the request, it closes.
- No response or error is ever sent to the client.
This is causing the issue below, which has STR:
https://github.com/firefox-devtools/debugger.html/issues/7989
The attached patch is an attempt to fix this problem, by keeping track of messages sent to the worker which haven't received a response yet. When the worker closes, error responses are sent for each of those messages. This does work, but I don't know how correct it is.
Assignee | ||
Updated•7 years ago
|
Comment 1•7 years ago
|
||
Assignee | ||
Comment 2•7 years ago
|
||
(In reply to Alexandre Poirot [:ochameau] from comment #1)
Is it a very rare race condition? Or does the workerClients list do not get
updated at all when the worker is closed? Or not updated quickly enough?
The STR above happen consistently. As far as I know the worker clients won't be updated until after the workers in the server have closed, but regardless we should be able to send requests to the worker thread at any time and get back either a response or an error.
I don't know if it may help to listen for workerTargetFront.once("close",
()=>{}) in order to remove worker from the list more quickly?
In theory, the Target front should be destroyed when the worker is destroyed.
C++ API should call this nsIWorkerDebugger.onClose listener method:
https://searchfox.org/mozilla-central/rev/
4587d146681b16ff9878a6fdcba53b04f76abe1d/devtools/server/actors/targets/
worker.js#136
Itself should communicate to the frontend that the target close is to be
destroyed. This particular WorkerTargetFront is in the parent process, so
that it should still be able to run and communicate to the client after the
worker is destroyed.
And then, in theory, all the child client and fronts, including the thread
client should be destroyed. I know we do have something to destroy pending
Fronts requests:
https://searchfox.org/mozilla-central/source/devtools/shared/protocol.
js#1292-1300
But I'm not sure if the old client, like ThreadClient are having a similar
feature. Yulia is now looking into bug 1494796, which is aiming to convert
it to protocol.js front.
This is this code, which looks like something that should impact the old
clients:
https://searchfox.org/mozilla-central/rev/
4587d146681b16ff9878a6fdcba53b04f76abe1d/devtools/shared/client/debugger-
client.js#669-676
It could be interesting ensuring this works as expected for workers.
The destroy() method in Front looks like it would work here, since it will reject all outstanding requests on the front. Is there an ETA for bug 1494796? Right now this is being worked around (https://github.com/firefox-devtools/debugger.html/pull/7996) in a way that can affect the UX where breakpoints in workers might not be hit as expected.
Updated•7 years ago
|
Comment 3•6 years ago
|
||
Brian, what is the status of this?
Assignee | ||
Comment 4•6 years ago
|
||
Once bug 1494796 is fixed, this issue should be fixed as well and the client can make sure breakpoints have been added/removed from workers before resuming execution.
Updated•6 years ago
|
Assignee | ||
Comment 5•6 years ago
|
||
Assignee | ||
Comment 6•6 years ago
|
||
Now that bug 1494796 has landed, this should be fixed. The patch I just posted waits on all threads when sending messages to the server. With this patch applied I can't reproduce the STR in comment 0.
Updated•6 years ago
|
Comment 8•6 years ago
|
||
bugherder |
Description
•