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

View File

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