Skip to content
Permalink
Browse files

Fix bug that prevents extension from working when access token is exp…

…ired (closes #125)
  • Loading branch information
rafaelgssa committed Dec 28, 2019
1 parent f623149 commit 763b492e1cd7bbe7db58c312cd838d1beb54a6d8
Showing with 8 additions and 4 deletions.
  1. +1 −1 package-lock.json
  2. +3 −0 src/class/Request.js
  3. +4 −3 src/modules/background/index.js

Some generated files are not rendered by default. Learn more.

@@ -7,6 +7,9 @@ class Request {
if (!Shared.isBackgroundPage() && !options.url.match(location.host)) {
try {
const response = await browser.runtime.sendMessage({ type: `request`, options: JSON.stringify(options) });
if (response.error) {
throw response;
}
options.success(response);
} catch (error) {
options.error(error.status, error.responseText, error.options);
@@ -38,7 +38,7 @@ if (chrome && chrome.declarativeContent) {
}

browser.runtime.onMessage.addListener((request, sender) => {
return new Promise(async (resolve, reject) => {
return new Promise(async resolve => {
switch (request.type) {
case `getApiDefs`:
// noinspection JSIgnoredPromiseFromCall
@@ -113,8 +113,9 @@ browser.runtime.onMessage.addListener((request, sender) => {
try {
const response = await Request.sendAndWait(options);
resolve(response);
} catch (error) {
reject(error);
} catch (response) {
response.error = true;
resolve(response);
}
return;
}

0 comments on commit 763b492

Please sign in to comment.
You can’t perform that action at this time.