You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: 'login' event is not emitted when the HTTP request is sent from the 'main' process using 'net.fetch()' on Windows and MacOS #44249
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
32.1.2
What operating system(s) are you using?
Other (specify below)
Operating System Version
MacOS Sonoma, Windows 11, Debian (Docker)
What arch are you using?
Other (specify below)
Last Known Working Electron version
No response
Expected Behavior
I have developed some tests to validate the behaviour of net.fetch() / fetch() on Windows, MacOS and Linux when sending HTTP(S) requests from the main process, from a renderer process and from a utility process. More specifically, I wanted to check the integration with the OS network settings and trust store when dealing with web proxies and self-signed certificates. See @hackolade/fetch for more details about my approach.
I expected net.fetch() / fetch() to behave consistently whatever the process and the operating system.
Actual Behavior
When sending HTTP requests through a web proxy that requires basic authentication, I observed the following:
On Linux, the 'login' event is properly emitted for all processes: main, renderer and utility. As a consequence, the request reaches the server in all cases.
On MacOS and Windows, the 'login' event is only emitted for a renderer process and a utility process. It is not emitted when sending the request using net.fetch() from the main process. As a consequence, that request fails with HTTP 407 Proxy Authentication Required.
So how am I supposed to deal with that case?
Note that I created a separate issue for the problem with setCertificateVerifyProc(): see #44264.
@thomas-jakemeyn could you please create a standalone sample for this issue specifically? Linking your full fetch repo still requires we make assumptions and introduces extra margin for error in triage.
Hello @thomas-jakemeyn. Thanks for reporting this and helping to make Electron better!
Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.
Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.
Now adding the
blocked/need-reproNeeds a test case to reproduce the bug
label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.
I do a variant of 2: Before using net.fetch for the first time, I call net.request once with a known URL. If a login is required, I handle it there. It is thus stored in the session and available in all subsequent uses of net.fetch.
More effort than it should be, but to me better than the other solutions.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.
Activity
codebytere commentedon Oct 16, 2024
@thomas-jakemeyn could you please create a standalone sample for this issue specifically? Linking your full fetch repo still requires we make assumptions and introduces extra margin for error in triage.
thomas-jakemeyn commentedon Oct 16, 2024
Hello @codebytere,
For reproducing this problem, you need more than just a Electron application. You also need to:
That's exactly what my repository contains. It provides a containerised environment where you can easily reproduce the problem...
mckravchyk commentedon Oct 30, 2024
I'm not getting the login event for Basic Auth in the main process on Linux either, v33.0.2 Please also consider Session.fetch.
electron-issue-triage commentedon Nov 16, 2024
Hello @thomas-jakemeyn. Thanks for reporting this and helping to make Electron better!
Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.
Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.
Now adding the blocked/need-reproNeeds a test case to reproduce the bug
label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.
xiaoma13 commentedon Nov 17, 2024
@thomas-jakemeyn Have you solved your problem? I encountered the same difficulty.
9 remaining items
DCzajkowski commentedon Apr 17, 2025
To be fair, the docs state that it will be fired only for renderer and utility processes:
I think the go-to solution used to be attaching the login event on
net.request:However, that is not possible with the
fetchimplementation fromnet.Current solutions to work around this issue until its UX improves:
net.fetch, usenet.requestwith.on('login', callback)handler.yarn patchor similar) by modifyingfetchimplementation to use the.on('login', callback)handler:electron/lib/browser/api/net-fetch.ts
Line 18 in 352a403
datenreisender commentedon May 16, 2025
I do a variant of 2: Before using
net.fetchfor the first time, I callnet.requestonce with a known URL. If a login is required, I handle it there. It is thus stored in the session and available in all subsequent uses ofnet.fetch.More effort than it should be, but to me better than the other solutions.
thomas-jakemeyn commentedon Jun 26, 2025
This issue still happens with electron 37.1.0.
electron-issue-triage commentedon Sep 25, 2025
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
thomas-jakemeyn commentedon Sep 25, 2025
bump
electron-issue-triage commentedon Dec 25, 2025
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
yaoweiprc commentedon Jan 15, 2026
bump
electron-issue-triage commentedon Apr 16, 2026
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
electron-issue-triage commentedon May 16, 2026
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.