I am working on proxy extension for chrome browser. My extension sets proxy config of the browser using:
chrome.proxy.settings.set({
value: config,
scope: 'regular',
});
Where config uses fixed_servers
mode.
Proxy servers require authentication, therefore I have:
chrome.webRequest.onAuthRequired.addListener(details => {
// Some logic
return {
authCredentials: {
username: usernameValue,
password: passwordValue,
},
};
});
Up until latest 71st Chrome version this logic was working as expected:
Browser boots > extensions initialized > all traffic goes through proxy and auth requests from proxy server are handled by listener
.
Since 71st version it seems that browser doesn't wait for extensions to be initialized(issue appears after Hard Quit, i.e. using command + Q
) and starts sending requests. Since proxy config is already set:
Requests go through proxy > proxy server requests authentication > extension is still not initialized by browser, therefore auth request listener is not added in the background as well - since there is nothing to intercept auth requests - native auth prompt is sown for the user
.
This ends up in a very bad UX + moments later when extension gets initialized, listener is already in place, so user either can fill the prompt and submit, or simply cancel - anyway proxy and its auth works.
I am looking for solution for this situation. Maybe there is a way to set some config for the browser that prevents it from doing requests until certain extension is initialized, or some way to suspend/reset/clear proxy config before browser quit(then I could manually set proxy again on init). Or any other fix for a given situation.
I've already tried to us chrome.windows
methods to monitor when browser windows are created and removed and on last one being removed tried calling chrome.proxy.settings.clear({ scope: 'regular' }, function() {...});
, but as I figured out, only sync
manage to happen before quit, while async
do not, hence chrome.proxy.settings.clear()
is of no use.
I am thankful in advance for any tips, suggestions, solutions/hacks and etc.