[webRequest.onHeadersReceived] Not all requests show modified headers
- Dominant language
- C++
- Stars
- 123k
- Forks
- 17.5k
- Avg merge
- 14h 28m
- Merged PRs (30d)
- 870
Description
### Preflight Checklist
- [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [x] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.
### Electron Version
34.0.0
### What operating system(s) are you using?
Windows
### Operating System Version
Windows 10
### What arch are you using?
x64
### Last Known Working Electron version
14.2.9
### Expected Behavior
All requests that are handled with `onHeadersReceived` should show modified headers (if they are being modified in the handler)
### Actual Behavior
Some requests do not show the modified headers.
Example:
```
electron.session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
console.log(details.url, details.responseHeaders);
if (details.responseHeaders) {
details.responseHeaders["test"] = ["1"];
}
callback({cancel: false, responseHeaders: details.responseHeaders});
});
```
I am setting a "test" header to each request
Navigating to google.com does not show the header in the first request:

It does appear in the second request though
### Testcase Gist URL
https://gist.github.com/t57ser/b97184b3c8772a8ccf7cb600ceac1202
### Additional Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.