github-account-switcher icon indicating copy to clipboard operation
github-account-switcher copied to clipboard

Account switching stops

Open ittayd opened this issue 1 year ago • 23 comments

After some time (a day or so) of running, the extension stops switching accounts. Not via rules nor manually.

I don't know how to analyze this. In the console I see this: lockdown-run.js:17 Lockdown failed: TypeError: At intrinsics.Object.groupBy expected boolean not function at isAllowedPropertyValue (lockdown-install.js:1:53384) at isAllowedProperty (lockdown-install.js:1:53807) at visitProperties (lockdown-install.js:1:55095) at isAllowedPropertyValue (lockdown-install.js:1:53041) at isAllowedProperty (lockdown-install.js:1:53807) at visitProperties (lockdown-install.js:1:55095) at lockdown-install.js:1:55523 at repairIntrinsics (lockdown-install.js:1:144597) at lockdown-install.js:1:145462 at lockdown-run.js:4:3 (anonymous) @ lockdown-run.js:17 Show 1 more frame Show less lockdown-more.js:99 Protecting intrinsics failed: ReferenceError: harden is not defined at lockdown-more.js:69:13 at Set.forEach () at protectIntrinsics (lockdown-more.js:44:22) at lockdown-more.js:97:5 (anonymous) @ lockdown-more.js:99 Show 1 more frame Show less VM1245:11 Refused to get unsafe header "6" t @ content.min.js:137 (anonymous) @ content.min.js:151 (anonymous) @ VM1245:11 l @ inpage.js:17 c @ inpage.js:17 (anonymous) @ inpage.js:17 (anonymous) @ inpage.js:17 85 @ inpage.js:17 i @ inpage.js:1 (anonymous) @ inpage.js:1 (anonymous) @ inpage.js:1 (anonymous) @ inpage.js:1 1.../../shared/modules/provider-injection @ inpage.js:1 i @ inpage.js:1 e @ inpage.js:1 (anonymous) @ inpage.js:1 (anonymous) @ contentscript.js:1 1.../../shared/constants/app @ contentscript.js:1 i @ contentscript.js:1 e @ contentscript.js:1 (anonymous) @ contentscript.js:1 Show 7 more frames Show less VM1245:11 Refused to get unsafe header "6" t @ content.min.js:137 (anonymous) @ content.min.js:151 (anonymous) @ VM1245:11 l @ inpage.js:17 a.setDefaultLevel @ inpage.js:17 (anonymous) @ inpage.js:1 (anonymous) @ inpage.js:1 1.../../shared/modules/provider-injection @ inpage.js:1 i @ inpage.js:1 e @ inpage.js:1 (anonymous) @ inpage.js:1 (anonymous) @ contentscript.js:1 1.../../shared/constants/app @ contentscript.js:1 i @ contentscript.js:1 e @ contentscript.js:1 (anonymous) @ contentscript.js:1 Show 7 more frames Show less Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "font-src github.githubassets.com".

ittayd avatar Sep 20 '23 12:09 ittayd

The error is from the lockdown-install.js, which belongs to the MetaMask extension. For your problem, I suggest you reinstall the extension or check the switching rules.

yuezk avatar Sep 21 '23 00:09 yuezk

I disabled the extension and the error persists. My rules are .* for ittayd and some other patterns (/abcd.*) for ittaysw. As you can see from this comment, account switcher is stuck on ittaysw even though the URL does not match the more specific patterns (and does match .* of course).

ittaysw avatar Oct 05 '23 07:10 ittaysw

I see tons of messages (several per second) like the below in the service worker console: synced accounts (2) [{…}, {…}]0: {name: 'ittayd', cookies: Array(12), active: false, avatarUrl: 'https://avatars.githubusercontent.com/u/33328?s=100&v=4', expiresAt: Tue Oct 10 2023 10:12:52 GMT+0300 (Israel Daylight Time)}1: {name: 'ittaysw', cookies: Array(12), active: true, avatarUrl: 'https://avatars.githubusercontent.com/u/107039793?s=100&v=4', expiresAt: Tue Oct 10 2023 10:12:52 GMT+0300 (Israel Daylight Time)}length: 2[[Prototype]]: Array(0) index.ts.346d2117.js:1 Current dynamic rules: (3) [{…}, {…}, {…}]0: {action: {…}, condition: {…}, id: 1, priority: 1}1: {action: {…}, condition: {…}, id: 2, priority: 1}2: {action: {…}, condition: {…}, id: 3, priority: 1}length: 3[[Prototype]]: Array(0) index.ts.346d2117.js:1 dotcom_user cookie removed index.ts.346d2117.js:1 New dotcom_user cookie ittaysw

image (note: not working whether the pattern is .* or /.*)

ittaysw avatar Oct 05 '23 07:10 ittaysw

Turned on error collection and saw this: Uncaught (in promise) Error: Extension context invalidated. assets/browser-polyfill.7e0c1479.js:1 (anonymous function)

ittaysw avatar Oct 05 '23 08:10 ittaysw

I logged out of all accounts, cleaned all github cookies, removed all rules. Then i logged in again (through the extension) and created the rules. I've done this before and after a while the extension stops working. But this time I also looked at the console and see onBeforeRequest: found an auto switch rule for url https://github.com/ Object, which I didn't see when the extension stopped working. Seems like it goes into some infinite loop without finding a matching rule.

ittayd avatar Oct 07 '23 12:10 ittayd

This just happens again, now there's no infinite loop in the service worker, instead, I see that ittayd is selected even though the URL matches one of the other patterns. Could it be the account attribute that appears in the conditions in console?

ittayd avatar Oct 09 '23 11:10 ittayd

Note that even though 'ittayd' is selected, when I load the repository I get a "Confirm your account recovery settings" window and after I confirm there are errors

ittayd avatar Oct 09 '23 11:10 ittayd

Deleting cookies and reloading the page doesn't help

ittayd avatar Oct 09 '23 11:10 ittayd

I removed the .* rule and can't manually switch to ittaysw at the home page or otherwise.

ittayd avatar Oct 09 '23 11:10 ittayd

@ittayd, Can you provide the accounts you want to switch? So that I can give help on the auto-switching rules.

yuezk avatar Oct 10 '23 12:10 yuezk

ittaysw and ittayd (those you can see in the thread)

ittayd avatar Oct 11 '23 05:10 ittayd

I disabled the extension and the error persists. My rules are .* for ittayd and some other patterns (/abcd.*) for ittaysw. As you can see from this comment, account switcher is stuck on ittaysw even though the URL does not match the more specific patterns (and does match .* of course).

I'm afraid the rule .* is too general. You need more specific rules to let the auto-switching work. It's better to ensure that there are no intersections among the rules.

yuezk avatar Oct 11 '23 13:10 yuezk

But if I don't have this rule then the profile will never auto switch to ittayd. After it switches to ittaysw, I'll need to manually switch to ittayd. Why is it hard to go over the rules one by one and switch on the first match?

ittayd avatar Oct 11 '23 19:10 ittayd

Why is it hard to go over the rules one by one and switch on the first match?

It might be because the priority property is the same for all the rules. https://github.com/yuezk/github-account-switcher/blob/a8418579edf9e6460379f7b5f9af07ca8f2bf043/src/background/index.ts#L74

Back to your problem, if you have two accounts, you could define two rules for auto-switching. You can define one regexp for one account. And define a regexp, which is the opposite of the previous one. Then auto-switching rules could work. If you can describe all the conditions, I could try to give the regexp.

yuezk avatar Oct 12 '23 10:10 yuezk

So allow me to set the priority of rules, or, set the priority by their visual order in the plugin's dialoge.

I'll try the opposite regex thing

ittaysw avatar Oct 16 '23 04:10 ittaysw

I now see the error Rule with id 1 specifies an incorrect value for the "regexFilter" key.. When I test the regex in the console it works. Here it is ^((?!(/.*starkware.*|/.*starknet.*)).)*

ittaysw avatar Oct 16 '23 05:10 ittaysw

The syntax of the regexFilter is https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#:~:text=Default%20is%20false.-,regexFilter,-string%C2%A0optional.

But I didn't see any error for your regexp.

yuezk avatar Oct 16 '23 08:10 yuezk

I think there's a bug in the code somewhere that makes the extension to stop selecting the right rule. I also think it should iterate on rules according to their order in the UX and take the last match. That way people can put a general account rule first and then narrow. Alternatively, there should be an option to set a default account if no rule matches.

ittaysw avatar Oct 17 '23 06:10 ittaysw

Note that after the bug happens I can't switch manually (the door icon in the extension) or exit an account (the x button)

ittaysw avatar Oct 17 '23 06:10 ittaysw

When I right click the extension and choose "inspect pop-up" and go to the Application tab, the session and local and shared storage seem to be empty

ittaysw avatar Oct 17 '23 06:10 ittaysw

Even if I remove the 'ittaysw' profile from the extension, it loggs me as ittaysw. I delete all github cookies and load the homepage and it logs me as ittaysw (i disable it, remove all cookies and load the homepage and am not logged in)

ittaysw avatar Oct 17 '23 06:10 ittaysw

And now I see the profile is back in the extension...

ittaysw avatar Oct 17 '23 06:10 ittaysw

I managed to remove the profiles from the extensions. In github try to login, get an error page. Disabled the extension, try to login, works fine.

The extension probably has a bug where it keeps a mangled login in storage somewhere, which it tries to apply, but fails.

ittayd avatar Oct 17 '23 06:10 ittayd