Fix muted errors

New bug spotted: "GETed with success" is logged twice for
proxy.pac.
This commit is contained in:
ilyaigpetrov 2020-10-13 16:27:50 +00:00
parent 7037af70ca
commit 17989f4735
2 changed files with 52 additions and 48 deletions

View File

@ -634,8 +634,8 @@ ${
if (ifNothingToCook) { if (ifNothingToCook) {
return originalSet(details, cb); return originalSet(details, cb);
} }
const getPacData = (cb) => const getPacData = (getPacCb) =>
pac.data ? cb(null, pac.data) : window.apis.httpLib.get(autoConfigUrl, cb); pac.data ? getPacCb(null, pac.data) : window.apis.httpLib.get(autoConfigUrl, getPacCb);
getPacData((err, pacData) => { getPacData((err, pacData) => {
if (err) { if (err) {
@ -644,27 +644,27 @@ ${
} }
const pacMods = getCurrentConfigs(); const pacMods = getCurrentConfigs();
const cookedData = pacKitchen.cook( pacData, pacMods ); const cookedData = pacKitchen.cook( pacData, pacMods );
const setCb = (/* No args. */) => {
kitchenState(ifIncontinence, null);
cb && cb();
};
if (window.apis.platform.ifFirefox) { if (window.apis.platform.ifFirefox) {
const autoConfigUrl = URL.createObjectURL(new Blob([cookedData], { const autoConfigUrl = URL.createObjectURL(new Blob([cookedData], {
type: 'application/x-ns-proxy-autoconfig', type: 'application/x-ns-proxy-autoconfig',
})); }));
originalSet({ return originalSet({
value: { value: {
proxyType: 'autoConfig', proxyType: 'autoConfig',
autoConfigUrl, autoConfigUrl,
}, },
}, chromified(cb)); }, setCb);
return;
} }
details.value.pacScript.data = cookedData; details.value.pacScript.data = cookedData;
originalSet({value: details.value}, (/* No args. */) => { return originalSet({ value: details.value }, setCb);
kitchenState(ifIncontinence, null);
cb && cb();
});
}); });
}; };

View File

@ -66,12 +66,15 @@
return; return;
} }
delete settings.levelOfControl; delete settings.levelOfControl;
const setProxyAsync = () => new Promise((setResolve, setReject) => const setProxyAsync = () => new Promise((setResolve, setReject) => {
console.log('Restoring chrome proxy settings...');
chrome.proxy.settings.set( chrome.proxy.settings.set(
settings, settings,
chromified((err) => err ? setReject(err) : setResolve()), chromified((err) => err ? setReject(err) : setResolve()),
),
); );
});
console.log('Clearing chrome proxy settings...');
chrome.proxy.settings.clear({}, chromified((clearErr) => { chrome.proxy.settings.clear({}, chromified((clearErr) => {
if (clearErr) { if (clearErr) {
reject(clearErr); reject(clearErr);
@ -86,12 +89,6 @@
pacData = mandatory(), cb = throwIfError, pacData = mandatory(), cb = throwIfError,
) { ) {
console.log('Clearing chrome proxy settings...');
chrome.proxy.settings.clear({}, chromified((clearErr) => {
if (clearErr) {
return cb(clearErr);
}
const config = { const config = {
mode: 'pac_script', mode: 'pac_script',
pacScript: { pacScript: {
@ -102,6 +99,7 @@
console.log('Setting chrome proxy settings...'); console.log('Setting chrome proxy settings...');
chrome.proxy.settings.set( { value: config }, chromified((err) => { chrome.proxy.settings.set( { value: config }, chromified((err) => {
console.log('ERRORR?:', err);
if (err) { if (err) {
return cb(err); return cb(err);
} }
@ -115,13 +113,12 @@
); );
} }
console.log('Successfuly set PAC in proxy settings..'); console.log('Successfuly set PAC in proxy settings.');
cb(); cb();
}); });
})); }));
}));
}; };
const updatePacProxyIps = function updatePacProxyIps( const updatePacProxyIps = function updatePacProxyIps(
@ -186,7 +183,15 @@
), ),
), ),
Promise.reject(), Promise.reject(),
)/*
.catch(
clarifyThen(
chrome.i18n.getMessage('FailedToDownloadPacScriptFromAddresses') + ': [ '
+ provider.pacUrls.join(' , ') + ' ].',
cb,
), ),
)
*/
); );
pacDataPromise.then( pacDataPromise.then(
@ -200,7 +205,6 @@
Object.assign(res || {}, {lastModified: lastModifiedStr}), Object.assign(res || {}, {lastModified: lastModifiedStr}),
), ),
); );
}, },
clarifyThen( clarifyThen(
@ -208,7 +212,6 @@
+ provider.pacUrls.join(' , ') + ' ].', + provider.pacUrls.join(' , ') + ' ].',
cb, cb,
), ),
); );
}; };
@ -540,7 +543,7 @@
'Periodic PAC update triggered:', 'Periodic PAC update triggered:',
new Date().toLocaleString('ru-RU'), new Date().toLocaleString('ru-RU'),
); );
antiCensorRu.syncWithPacProviderAsync(() => {/* swallow */}); antiCensorRu.syncWithPacProviderAsync(() => { /* Swallow. */ });
} }
}) })
@ -564,7 +567,8 @@
// INSTALL // INSTALL
console.log('Installing...'); console.log('Installing...');
handlers.switch('on', 'ext-error'); handlers.switch('on', 'ext-error');
return chrome.runtime.openOptionsPage(); chrome.runtime.openOptionsPage();
return;
} }
// LAUNCH, RELOAD, UPDATE // LAUNCH, RELOAD, UPDATE