Only raise OfflineError when actually offline#172708
Merged
sandy081 merged 1 commit intomicrosoft:mainfrom Feb 3, 2023
Merged
Conversation
sandy081
approved these changes
Feb 2, 2023
bpasero
approved these changes
Feb 2, 2023
c-claeys
pushed a commit
to c-claeys/vscode
that referenced
this pull request
Feb 16, 2023
Only raise OfflineError when actually offline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #147510
Fixes #171130
At least on macOS,
navigator.onLineseems to be based on the status of the "connectivity icon":https://support.apple.com/en-gb/guide/mac-help/mchlcedc581e/mac
It's possible to have macOS think it's not connected while there's actually a proxy configured that allows HTTP(S) connectivity:
vmnet2, the host interface for VMware Fusion) is connected to a virtual machine with a bridged network interface to W-Fi/Ethernetvmnet2to a proxy virtual machine and out to the internetThis configuration will make the Wi-Fi icon look like "No internet", even though there's a proxy available through which applications (e.g. VS Code) can talk to the internet.
However, since #141762, I have to "spoof" macOS into thinking it has network connectivity (change the icon from "No internet" to a "connected" state). Even though VS Code can access the marketplace fine through the configure proxy,
navigator.onLinewill always returnfalseif the Wi-Fi icon is not in a "connected" state. If I configure the main interface with a bogus, non-routable IP address, the Wi-Fi icon will change to a "connected" state (even though it can't actually reach anything). Nownavigator.onLinewill returntrue, and VS Code stops throwing errors.This change moves the throwing of the
OfflineErrorto when the request actually fails. The original intent of #141762 is maintained, but it's more accurate as it works around weirdnavigator.onLinequirks.