browser.webRequest.onCompleted response "tabId" value always -1
Categories
(WebExtensions :: Request Handling, defect, P3)
Tracking
(Not tracked)
People
(Reporter: tlissak, Unassigned)
Details
Attachments
(1 file)
|
592 bytes,
application/x-zip-compressed
|
Details |
Updated•8 years ago
|
Updated•8 years ago
|
Updated•4 years ago
|
Comment 2•3 years ago
|
||
I see similar behavior in Firefox 117.0.
Some of completed requests tab have tabId -1.
Is this issue open or should I create a new bug?
Example debug extension console log:
Request happened for tabId: 42 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 16 background.js:3:7
Request happened for tabId: -1 2 background.js:3:7
Request happened for tabId: 42 6 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 2 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 22 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 2 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 13 background.js:3:7
Request happened for tabId: -1 2 background.js:3:7
Request happened for tabId: 42 2 background.js:3:7
Request happened for tabId: -1 2 background.js:3:7
Request happened for tabId: 42 5 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 3 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 11 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 22 background.js:3:7
Request happened for tabId: -1 3 background.js:3:7
Request happened for tabId: 42 background.js:3:7
Request happened for tabId: -1 5 background.js:3:7
Request happened for tabId: 42 8 background.js:3:7
Request happened for tabId: -1 background.js:3:7
Request happened for tabId: 42 3 background.js:3:7
I can confirm that this bug still exists in Firefox 130.0 (or was introduced back as a regression).
The tabId will only be set for additional requests that are caused by the request with type main_frame.
Strangely enough, adding an "empty" handler to the browser.webRequest.onResponseStarted fixes the issue:
browser.webRequest.onResponseStarted.addListener(
() => {},
{ urls: ['<all_urls>'] }, // Listen to all URLs
['responseHeaders'],
);
I can only assume that the cause is a race condition that is fixed by the slight delay introduced by the additional handler.
The bug only occured in a fresh Firefox profile. Upon further investigation I noticed that any other extension using the additional handler fixes the issue.
Comment 4•2 years ago
|
||
Oh man, I've just spend two hours trying to find out why the tabId is always negative for the first request, even in the ESR 128.
And yet in my "production" environment it works as expected (where I have adblocker installed, which likely registers onResponseStarted).
Thank you Simon for the workaround!
As mentioned above, it's likely a regression in 117, since I was developing using ESR 115 just recently and this bug wasn't there.
Description
•