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•7 years ago
|
Updated•6 years ago
|
Updated•2 years ago
|
Comment 2•1 year 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.
Description
•