Skip to content

Only raise OfflineError when actually offline#172708

Merged
sandy081 merged 1 commit intomicrosoft:mainfrom
Schamper:main
Feb 3, 2023
Merged

Only raise OfflineError when actually offline#172708
sandy081 merged 1 commit intomicrosoft:mainfrom
Schamper:main

Conversation

@Schamper
Copy link
Contributor

@Schamper Schamper commented Jan 28, 2023

Fixes #147510
Fixes #171130

At least on macOS, navigator.onLine seems 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:

  • The main interface (Wi-Fi/Ethernet) is configured with TCP/IP -> IPv4 set to "Disabled"
  • A virtual interface (e.g. vmnet2, the host interface for VMware Fusion) is connected to a virtual machine with a bridged network interface to W-Fi/Ethernet
  • A HTTP(S) proxy is configured so that network traffic is routed over vmnet2 to a proxy virtual machine and out to the internet

This 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.onLine will always return false if 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). Now navigator.onLine will return true, and VS Code stops throwing errors.

This change moves the throwing of the OfflineError to when the request actually fails. The original intent of #141762 is maintained, but it's more accurate as it works around weird navigator.onLine quirks.

@sandy081 sandy081 added this to the February 2023 milestone Feb 3, 2023
@sandy081 sandy081 merged commit fe8228c into microsoft:main Feb 3, 2023
c-claeys pushed a commit to c-claeys/vscode that referenced this pull request Feb 16, 2023
Only raise OfflineError when actually offline
@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS code claims I am offline, when I'm very much online Only report as being offline if a request fails

3 participants