microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.81k stars 29.12k forks source link

PWA: Cannot fetch files in a remote repo after going back online #141605

Closed kimadeline closed 2 years ago

kimadeline commented 2 years ago

Testing #141296

Repro steps:

joaomoreno commented 2 years ago

Yeah it seems some layer caches the error promises. Two possibilities:

  1. Core workbench services @bpasero
  2. Remote Repositories extension @joyceerhl
bpasero commented 2 years ago

Failed to fetch is not coming from any of my layers and is a good indication that the editor indeed attempts to "fetch".

We actually resolve the file from its location every time you switch tabs to poll for new changes.

joaomoreno commented 2 years ago

The problem is not the Failed to fetch per se, but rather that some code caches that error when it happens due to being offline and keeps returning it even after going online, when the promise would actually succeed.

bpasero commented 2 years ago

The console shows this error:

  ERR HttpError: Failed to fetch
    at eval (extension.js:117:7584)
    at Su.request (extension.js:119:25450)
    at Su.getBlobContent (extension.js:219:727)
    at Su.getFileContent (extension.js:219:1422)
    at vc.readFile (extension.js:112:14864)
    at Ys.readFile (extension.js:107:27024)

The extension is: https://github.vscode-unpkg.net/GitHub/remotehub/0.23.2022012602/extension/dist/browser/extension.js#vscode-extension:formatted

joyceerhl commented 2 years ago

@joaomoreno is spot on, RemoteHub constructs a filetree representing the repo contents where each file has a memoized getContent method that returns a promise resolving to the file contents. That's where the stacktrace above is coming from. We need to know when to clear out the memoized promise. ~We could use some heuristics like refetching the filetree when we see a 'failed to fetch' like the above.~ We shouldn't be caching promises which resolve to errors.

meganrogge commented 2 years ago

Still reproduces for me Offline: Screen Shot 2022-02-25 at 11 36 22 AM Back online: Screen Shot 2022-02-25 at 11 36 33 AM

joyceerhl commented 2 years ago

Sorry, forgot to publish a new pre-release with the fixes. Just published one and verified it works for me in the PWA--please give it a try again and thank you for testing!