subdavis / Tusk

🐘 🔒 KeePass-compatible browser extension for filling passwords.
https://subdavis.com/Tusk
Other
476 stars 73 forks source link

Add runtime.lastError checking to allOriginPermissions #214

Closed zmilonas closed 6 years ago

zmilonas commented 6 years ago

I couldn't reproduce. macOS 10.13.6 with Chrome 70.0.3513.0 (Official Build) canary

But I read up on this errors and this should fix it.

@subdavis

subdavis commented 6 years ago

Could you clarify - does this fix it or just log the error to console?

FYI, the error was already being logged to console by chrome.

zmilonas commented 6 years ago

Both

per https://stackoverflow.com/a/28432087

Chrome added checks that chrome.runtime.lastError is actually checked (evaluated) in a callback. If not, it considers this to be an unhandled exception, and throws this error.

subdavis commented 6 years ago

Oh interesting. That's a good find - I looked for docs and didn't see that SO question.

Is that a solution though? The chrome permission call is still failing. I'd actually prefer it not be handled, since this gives the developer a stack trace to go along with the error.

I still need to figure out how to make the permissions request succeed in all cases. I have a feeling Vue.js watched properties are making it hard for the browser to determine user interaction. I'm going to try replacing that with a click handler.

May I close this, or do you have a reason for wanting to handle this error?

zmilonas commented 6 years ago

I'll install other versions of Chrome later today and will run some tests to try and reproduce this. I'll close if I find nothing

I guess this kind of way may work as well.

chrome.tabs.sendMessage(tab.id, obj, options, () => {
       if (chrome.runtime.lastError) {
       // Some error happened
       }
       resolve();
});

from: https://github.com/bitwarden/browser/blob/master/src/browser/browserApi.ts#L94