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
I agree to follow the Code of Conduct that this project adheres to.
I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
Electron Version:
7.1.1
Operating System:
Windows 10 (1909)
Last Known Working Electron version:
6.1.4
Expected Behavior
Setting a proxy with setProxy and a pac file works.
Actual Behavior
So i'm trying to set a proxy using setProxy with a pac file. I added a partition to my webview and use the same one when using setProxy. It's not catching an error but when I use resolveProxy the promise is empty. If i check the ip it's my normal one not the proxy one.
Additional Information
If i use proxyRules everything works as intended.
My pacFile should be fine: function FindProxyForURL(url, host) { return "PROXY proxy.example.com:8080"; }
This is the description in the chromium error list:
A mandatory proxy configuration could not be used. Currently this means that a mandatory PAC script could not be fetched, parsed or executed.
Can you add the snippet that shows your session.setProxy(config) and your config object. Are you sure the path is correct to your pacfile? (e.g. console.log the file, or try to read it with const pacFileString = await fs.readFile(pacFile, "utf8");
When i read the file like you proposed the output is equal to my file.
The console output looks like this:
proxy successfully set
data read: function FindProxyForURL(url, host) { return "PROXY proxy.example.com:8080"; }
resolved proxy:
Error: ERR_MANDATORY_PROXY_CONFIGURATION_FAILED (-131) loading 'https://www.google.com/'
at rejectAndCleanup (electron/js2c/browser_init.js:5808:21)
at WebContents.failListener (electron/js2c/browser_init.js:5818:11)
at WebContents.emit (events.js:203:13) {
errno: -131,
code: 'ERR_MANDATORY_PROXY_CONFIGURATION_FAILED',
url: 'https://www.google.com/'
}
As you can see i can set the proxy without catching an error, but when trying to resolve the promise is empty. When i use loadURL afterwards it returns the chromium error. I've also made sure the proxy works.
The latest version of electron I've tried is 6.1.4. This works. I don't know if this is helpful information though. setProxy since changed from using callbacks to promises.
Seems to make sense (I presume the proxy.example:8080 is a dummy value here). If 6.1.4 this works, and 7.1.1 not it seems like a bug. I don't work on Electron, so can maybe only help with some dev ideas:
Two ideas:
What if your return "DIRECT" in FindProxyForURL? Does that also fail?
Do you need a pacscript? Can you not try what you want with the proxyRules object?
Activity
betavebow commentedon Nov 15, 2019
So I tried setting the proxy with the electron-quick-start project to minimize factors that could play a role.
If i follow the official docs: https://electronjs.org/docs/api/session, i get an error saying:
ERR_MANDATORY_PROXY_CONFIGURATION_FAILED (-131).This is the description in the chromium error list:
A mandatory proxy configuration could not be used. Currently this means that a mandatory PAC script could not be fetched, parsed or executed.
ymschaap commentedon Nov 20, 2019
Can you add the snippet that shows your session.setProxy(config) and your config object. Are you sure the path is correct to your pacfile? (e.g. console.log the file, or try to read it with
const pacFileString = await fs.readFile(pacFile, "utf8");betavebow commentedon Nov 20, 2019
This is my usage in the quick-start:
When i read the file like you proposed the output is equal to my file.
The console output looks like this:
As you can see i can set the proxy without catching an error, but when trying to resolve the promise is empty. When i use loadURL afterwards it returns the chromium error. I've also made sure the proxy works.
The latest version of electron I've tried is 6.1.4. This works. I don't know if this is helpful information though. setProxy since changed from using callbacks to promises.
ymschaap commentedon Nov 21, 2019
Seems to make sense (I presume the proxy.example:8080 is a dummy value here). If 6.1.4 this works, and 7.1.1 not it seems like a bug. I don't work on Electron, so can maybe only help with some dev ideas:
Two ideas:
What if your return "DIRECT" in FindProxyForURL? Does that also fail?
Do you need a pacscript? Can you not try what you want with the proxyRules object?
betavebow commentedon Nov 21, 2019
Yeah it's a dummy value. Direct doesn't seem to make a difference.
I have decided that I'll be sticking with 6.1.4 until this is resolved.
Thank you very much for your help!
cuixiping commentedon Mar 12, 2020
Same issue.
Electron v7.1.x (also v8.x.x) doesn't work with
file:URI, but works withhttp:URI.Electron v6.1.9 is OK.
I tested a simplest pac file.
D:\test.pacIn my
app.jsWorks well with
http:URI:Doesn't work with
file:URI:The error message is:
cuixiping commentedon Mar 14, 2020
I am sure that the
pacScriptvalue should not befile:url with electron v7.x.x or higher.My solution is using
data:url orhttp:url instead.For example:
iwind commentedon Aug 5, 2020
This fixed my issue.
iwind commentedon Aug 15, 2020
this works well, and 'text/plain' should be replaced with 'application/x-ns-proxy-autoconfig' as perfect.
wong1993 commentedon Feb 19, 2021
I found that
session.defaultSession.setProxy({}).then(() => {});worked fine to bypass proxy
electron-triage commentedon Mar 9, 2021
The Electron version reported on this issue is no longer supported. See our supported versions documentation.
If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.
Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.