vscode: Setting Sync: failed because of Unauthorized (401)
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version:
Version: 1.60.1 (user setup)
Commit: 83bd43bc519d15e50c4272c6cf5c1479df196a4d
Date: 2021-09-10T17:07:10.714Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.22000
Steps to Reproduce:
- Enable Settings Sync (with a Microsoft account, @live.com in case it matter)
- Wait 15-20 minutes, sync will eventually stop with an Unauthorized error
I can reproduce this problem on three different machines, both with the latest Stable and Insiders. The problem started last month for me but we were just a few days away from the August release so I decided to wait and see if the problem went away with the new version (it happened in the past). It didn’t.
Setting Sync Log:
[2021-09-14 18:14:00.571] [settingssync] [info] Auto Sync: Triggered by Interval
[2021-09-14 18:14:00.870] [settingssync] [info] Settings: No changes found during synchronizing settings.
[2021-09-14 18:14:00.884] [settingssync] [info] Keybindings: No changes found during synchronizing keybindings.
[2021-09-14 18:14:00.899] [settingssync] [info] Snippets: No changes found during synchronizing snippets.
[2021-09-14 18:14:01.175] [settingssync] [info] GlobalState: No changes found during synchronizing ui state.
[2021-09-14 18:14:01.417] [settingssync] [info] Extensions: No changes found during synchronizing extensions.
[2021-09-14 18:14:01.421] [settingssync] [info] Sync done. Took 679ms
[2021-09-14 18:19:01.439] [settingssync] [info] Auto Sync: Triggered by Interval
[2021-09-14 18:19:01.707] [settingssync] [info] Settings: No changes found during synchronizing settings.
[2021-09-14 18:19:01.749] [settingssync] [info] Keybindings: No changes found during synchronizing keybindings.
[2021-09-14 18:19:01.765] [settingssync] [info] Snippets: No changes found during synchronizing snippets.
[2021-09-14 18:19:02.031] [settingssync] [info] GlobalState: No changes found during synchronizing ui state.
[2021-09-14 18:19:02.277] [settingssync] [info] Extensions: No changes found during synchronizing extensions.
[2021-09-14 18:19:02.278] [settingssync] [info] Sync done. Took 688ms
[2021-09-14 18:24:02.283] [settingssync] [info] Auto Sync: Triggered by Interval
[2021-09-14 18:24:02.567] [settingssync] [info] Settings: No changes found during synchronizing settings.
[2021-09-14 18:24:02.583] [settingssync] [info] Keybindings: No changes found during synchronizing keybindings.
[2021-09-14 18:24:02.602] [settingssync] [info] Snippets: No changes found during synchronizing snippets.
[2021-09-14 18:24:02.897] [settingssync] [info] GlobalState: No changes found during synchronizing ui state.
[2021-09-14 18:24:03.125] [settingssync] [info] Extensions: No changes found during synchronizing extensions.
[2021-09-14 18:24:03.126] [settingssync] [info] Sync done. Took 698ms
[2021-09-14 18:29:03.136] [settingssync] [info] Auto Sync: Triggered by Interval
[2021-09-14 18:29:03.426] [settingssync] [info] Settings: No changes found during synchronizing settings.
[2021-09-14 18:29:03.442] [settingssync] [info] Keybindings: No changes found during synchronizing keybindings.
[2021-09-14 18:29:03.456] [settingssync] [info] Snippets: No changes found during synchronizing snippets.
[2021-09-14 18:29:03.720] [settingssync] [info] GlobalState: No changes found during synchronizing ui state.
[2021-09-14 18:29:03.959] [settingssync] [info] Extensions: No changes found during synchronizing extensions.
[2021-09-14 18:29:03.965] [settingssync] [info] Sync done. Took 654ms
[2021-09-14 18:34:03.973] [settingssync] [info] Auto Sync: Triggered by Interval
[2021-09-14 18:34:04.120] [settingssync] [info] Request failed {"url":"https://vscode-sync.trafficmanager.net/v1/manifest","status":401,"execution-id":"3a1b0766-8591-4179-ab40-e37a58352793"}
[2021-09-14 18:34:04.120] [settingssync] [info] Auto Sync: Suspended until auth token is available.
[2021-09-14 18:34:04.120] [settingssync] [info] Auto sync: Cancelled sync that is in progress
[2021-09-14 18:34:04.120] [settingssync] [info] Auto Sync: Stopped
[2021-09-14 18:34:04.121] [settingssync] [error] Unauthorized (UserDataSyncError) syncResource:unknown operationId:unknown: Request 'https://vscode-sync.trafficmanager.net/v1/manifest' failed because of Unauthorized (401).
at S.request (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:171737)
at async S.manifest (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:168934)
at async o.createSyncTask (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:140173)
at async u.doSync (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:134594)
[2021-09-14 18:34:04.148] [settingssync] [info] Auto Sync: Started
[2021-09-14 18:34:04.149] [settingssync] [info] Auto Sync: Triggered by Interval
[2021-09-14 18:34:04.176] [settingssync] [info] Request failed {"url":"https://vscode-sync.trafficmanager.net/v1/manifest","status":401,"execution-id":"4ceacf3f-3468-47d1-a83a-910db1f0a0e9"}
[2021-09-14 18:34:04.176] [settingssync] [info] Auto Sync: Suspended until auth token is available.
[2021-09-14 18:34:04.176] [settingssync] [info] Auto sync: Cancelled sync that is in progress
[2021-09-14 18:34:04.176] [settingssync] [info] Auto Sync: Stopped
[2021-09-14 18:34:04.177] [settingssync] [error] Unauthorized (UserDataSyncError) syncResource:unknown operationId:unknown: Request 'https://vscode-sync.trafficmanager.net/v1/manifest' failed because of Unauthorized (401).
at S.request (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:171737)
at async S.manifest (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:168934)
at async o.createSyncTask (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:140173)
at async u.doSync (vscode-file://vscode-app/c:/Users/carloc/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sharedProcess/sharedProcessMain.js:58:134594)
Things I tried (all with no luck):
- Logged off from the Microsoft account I use for sync
- Turn off Settings Sync on all my machines and VSCode instances
- Clear data in Cloud
One additional pointer: I sync both Stable and Insiders on the Stable channel. I remember at least one occurrence in the past where the two versions could not be sync’ed in the same channel because of some temporary incompatibility, is this still the case?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 60 (39 by maintainers)
Commits related to this issue
- remove keytar fallback in keychain and add a ton more logging to microsoft auth. ref #133201 — committed to microsoft/vscode by TylerLeonhardt 3 years ago
- #133201 add more logging — committed to microsoft/vscode by sandy081 3 years ago
fixed in #137083 . Will be included in 1.62.3 coming later this week.
Here are some fun learnings…
This value comes from a cracked open JWT used in the Microsoft Authentication extension
This value comes from the response of the API call that gave me said JWT
expis a unix time in seconds… theDate.now()at the time was1636660150974in ms.expires_inis simply in seconds…So if the docs say:
and
Who is right? 🙃
We currently refresh at a rate of 30 seconds before
expires_inwhich in the example above… would mean that the token is technically expired for a solid 4 and a half minutes before we refresh…I talked to @connor4312 about this and he says:
In our case, we don’t need to use a timestamp so the “refresh every 2/3rds of
expires_in” is a reasonable approach. This is what I’m gonna run with.So at the end of the day, a simple 1 line change of
expiresIn * 2/3replacingexpiresIn - 30… I’ve been running it for a few hours and haven’t seen any issues yet… let’s see how you all fare.The commit: https://github.com/microsoft/vscode/commit/f8b17200c1318f0b58090445cc1a6338da426e4e
I’m able to repro this and I’m filling the codebase with log statements since attaching a debugger doesn’t work in this instance.
It just takes over an hour to get a repro… figure out I’m missing X log statement… then rerun the whole experiment.
I am actively working on this - just want you all to know.
Thank you all so much for all the great information. I am feeling very confident that we have narrowed down the route cause and have fixed this issue 🎉
The fix for this will be in two parts.
That is marked as a candidate and will be in the release of vscode this week.
As an alternative to waiting, you can continue signing out of Microsoft until in no longer shows up on that list in the screenshot.
With all that said, that commit didn’t make the release cut off, unfortunately, so that won’t make it in to VS Code stable until next month. However, it will be in VS Code insiders starting later this week/next week.
Since there’s no more action needed besides waiting for these releases to happen, I will close this issue. If you end up using VS Code insiders starting next week and you still see this issue, please don’t hesitate to comment here or open a new issue.
Unfortunately the workaround does not work for me (I have even cleared all relevant cached creds from Credential Manager), I’ll test the fix when it comes out to Insiders
Just FYI, I pushed another commit with more logging and a potential fix.
Please give Insiders a go starting tomorrow and let me know.
👋 hi all.
We need more data as this is tricky to narrow down…
@sandy081 will be adding some additional logging around Settings Sync but this will only be in insiders for now so we need you folks to give that a go and share the logs as mentioned here https://github.com/microsoft/vscode/issues/133201#issuecomment-962285046
Hi, I’ve also been suffering from this bug for a few weeks now (in the previous version of VScode), and just today I received the new 1.62.0 stable October version, but the same problem persists: Every so often, sometimes about 30 minutes, sometimes instantaneously, several times consecutively, the error pops up.
I attach VSCode version, Microsoft Authentication and Setting Sync log, in case it helps.
Settings Sync Log (Note that I have detected several consecutive authentication errors.)
Microsoft Authentication Output
Looks like Stable has regressed on all my machines, the behavior and logs looks the same as what I previously shared above. Insiders is still running smoothly (for now)
Thanks Tyler. Will do!
@Jimbo99 I don’t think this is related but I’m not sure. Can you open a new issue (since this one is way to long)? And also attach the following:
Developer: Set Log Level...commandTraceMicrosoft AuthenticationOutput channelLog (Settings Sync)Output channelLog (Window)Output channelMarked as a candidate so that the change can be included in a 1.62.3 (if we do one)
Today’s Insiders has been running smoothly with Settings Sync enabled for over four hour, it never lasted this long without errors. Looks very promising
Added additional log statements. I would also request to provide us the screenshot of the accounts picker after clicking on sign in action in the prompt that says settings sync is suspended because of successive auth failures. Ideally a video would be great.
We’ll have a new stable next week so we’ll be able to really test things out then.
I’ve added a ton more logging on the Microsoft Auth side in that☝️ commit and I did move a few other things around… let’s see how it goes for you all. Please try out Insiders tomorrow.
If you still see the issue, please add the Microsoft Authentication Output channel here.
Here’s where it is for your reference: