Closed
Bug 1058632
Opened 11 years ago
Closed 5 years ago
webworker's importScripts() doesn't throw NETWORK_ERROR
Categories
(Core :: DOM: Workers, defect, P5)
Tracking
()
RESOLVED
INVALID
People
(Reporter: jakobmaier42, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.8 Safari/537.36
Steps to reproduce:
Call
"importScripts.apply(self, ["this_url_does_not_exist"]);"
or just
"importScripts("this_url_does_not_exist");"
within a webworker (dedicated worker).
Actual results:
Nothing, the script continued as nothing would have happened
Expected results:
According to the mozilla guides, this should throw a network_error:
https://developer.mozilla.org/de/docs/Web/Guide/Performance/Using_web_workers#Importing_scripts_and_libraries
| Reporter | ||
Comment 1•11 years ago
|
||
Note that in the example I tested I imported several files, and some of them do exist. But this shouldn't be relevant.
Comment 2•11 years ago
|
||
Was this from an HTTP site?
I bet workers don't check for HTTP error pages and just assume that if they got data everything is good...
Status: UNCONFIRMED → NEW
Component: General → DOM: Workers
Ever confirmed: true
| Reporter | ||
Comment 3•11 years ago
|
||
Actually it's from an https-page (self-signed), and the console shows the 404-not-found errors.
A difference to Chrome is, that firefox tries to load all files (and prints lots of 404's in the console), while chrome aborts the importing as soon as it found the first missing file.
| Reporter | ||
Updated•11 years ago
|
Severity: normal → major
We do check http results, http://mxr.mozilla.org/mozilla-central/source/dom/workers/ScriptLoader.cpp#440
Is that insufficient somehow?
Comment 5•11 years ago
|
||
Ah, I see.
So the issue is that all we do with loadInfo.mLoadResult is report it to console in ScriptExecutorRunnable::WorkerRun. We don't convert it into an exception to be thrown from importScripts.
Yeah, looks that way. http://mxr.mozilla.org/mozilla-central/source/dom/workers/ScriptLoader.cpp#736
Comment 7•11 years ago
|
||
> So the issue is that all we do with loadInfo.mLoadResult is report it to
> console in ScriptExecutorRunnable::WorkerRun. We don't convert it into an
> exception to be thrown from importScripts.
Actually we do this:
https://mxr.mozilla.org/mozilla-central/source/dom/workers/ScriptLoader.cpp#765
that throws an exception.
Comment 8•11 years ago
|
||
No, it reports an error. To the console. Via the error reporter. It doesn't create an exception to throw up the callstack... (Except in the Throw() case, perhaps, which I really hope we never hit, since nothing here would return false from the actual jsapi entry point!)
Updated•11 years ago
|
Flags: needinfo?(amarchesini)
Sorry, so the way this is supposed to work is that importScripts() blocks in a sync loop while all the network stuff happens: https://mxr.mozilla.org/mozilla-central/source/dom/workers/ScriptLoader.cpp#856
Then, each thing gets loaded by necko. If the load fails we're supposed to report here: https://mxr.mozilla.org/mozilla-central/source/dom/workers/ScriptLoader.cpp#765
The subtle thing there is that we exit early and don't set |loadInfo.mExecutionResult| to true. That means the final end result of importScripts() will be to throw an exception: https://mxr.mozilla.org/mozilla-central/source/dom/workers/ScriptLoader.cpp#802 which calls https://mxr.mozilla.org/mozilla-central/source/dom/workers/ScriptLoader.cpp#827 which passes |false| as the result.
That |false| result should be returned here: http://mxr.mozilla.org/mozilla-central/source/dom/workers/WorkerPrivate.cpp#4765 and we should throw the exception.
So clearly something isn't working as it's supposed to in this case, but the plumbing is all still in place I think.
Comment 10•11 years ago
|
||
Ben, thank you for explaining all that. So I finally sat down and wrote a test of my own:
https://web.mit.edu/bzbarsky/www/testcases/workers/test-importscripts-404.html
and I can't reproduce the "firefox tries to load all files (and prints lots of 404's in the console)" bit, nor the "no exception thrown" bit.
The exception thrown is not a NetworkError, but that's not surprising given what scriptloader::ReportLoadError is doing.
Reporter, how does the behavior on my testcase differ from what you're seeing on your testcase?
Flags: needinfo?(amarchesini) → needinfo?(jakobmaier42)
| Reporter | ||
Comment 11•11 years ago
|
||
The testcase you created works for me, the exception is created.
However, my testcase still doesn't throw exceptions and I don't see any major difference.
I called it with "importScripts(self, "./../../path/to/script1.js", "./../../path/to/script2.js");", and want to load about ~15 scripts with one call. Only one of the scripts does not exist (I think the missing script is somewhere in the middle of the list).
Flags: needinfo?(jakobmaier42)
| Reporter | ||
Comment 12•11 years ago
|
||
Sorry, of course I called it with "importScripts.apply(self, ...);"
Comment 13•11 years ago
|
||
Can you possibly link to your testcase? It's hard to debug something I can't reproduce...
Comment 14•9 years ago
|
||
Still trying to get hold of a testcase that actually shows the problem. We have a bunch of tests in our test suite now testing that importScripts throws NETWORK_ERROR as needed... and I still haven't been able to reproduce this issue as reported.
Flags: needinfo?(jakobmaier42)
Updated•8 years ago
|
Priority: -- → P5
Comment 15•5 years ago
|
||
As the reporter did not come back with any further information, we'll close this now.
Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(jakobmaier42)
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•