github-account-switcher
github-account-switcher copied to clipboard
Account switching stops
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 (
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".
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.
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 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
(note: not working whether the pattern is
.*
or /.*
)
Turned on error collection and saw this: Uncaught (in promise) Error: Extension context invalidated. assets/browser-polyfill.7e0c1479.js:1 (anonymous function)
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.
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?
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
Deleting cookies and reloading the page doesn't help
I removed the .* rule and can't manually switch to ittaysw at the home page or otherwise.
@ittayd, Can you provide the accounts you want to switch? So that I can give help on the auto-switching rules.
ittaysw and ittayd (those you can see in the thread)
I disabled the extension and the error persists. My rules are
.*
forittayd
and some other patterns (/abcd.*
) forittaysw
. 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.
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?
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.
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
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.*)).)*
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.
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.
Note that after the bug happens I can't switch manually (the door icon in the extension) or exit an account (the x button)
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
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)
And now I see the profile is back in the extension...
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.