microsoft / vscode

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

VS Code fails to start/open when offline #7570

Closed johnnyPescarul closed 5 years ago

johnnyPescarul commented 8 years ago

Steps to Reproduce:

  1. Install VS Code 1.2.0 and open first time while connected to internet
  2. Turn off data connection
  3. Try to restart VS Code (it does not open at all, either from shortcuts or exe)
bpasero commented 8 years ago

@johnnyPescarul any output when you try to run code --verbose from the command line in this case?

johnnyPescarul commented 8 years ago

@bpasero Sorry for the late reply, I didn't see the notification. I tried running "code --verbose" from command line and still nothing, not even one line. As soon as I connect to the internet, it works. I tried re-installing multiple times but I have the same behavior. I tried to replicate on a Windows 7 machine, but was not able to (so it seems to be limited to my Windows 8 machine).

bpasero commented 8 years ago

@johnnyPescarul does it return immediately when running "code --verbose"?

johnnyPescarul commented 8 years ago

@bpasero when I run it, it starts the process but it then hangs. It must be something early on since nothing is displayed with verbose flag on. Are there any logs generated?

bpasero commented 8 years ago

@johnnyPescarul any chance you could find out all the processes that we are able to spawn? this might get us closer to see where it hangs.

@joaomoreno could this be an issue with creating a connection to the shared process if you are offline?

joaomoreno commented 8 years ago

@bpasero Why the shared process? The window doesn't even seem to open...

bpasero commented 8 years ago

@joaomoreno the shared process (to my understanding) gets created from the main side. we have seen super funky behaviour when sending telemetry where the entire VM stops in some DNS lookup. Maybe the main side stops in a similar situation trying to establish a connection to the shared process.

joaomoreno commented 8 years ago

Very unlikely. The main process doesn't even connect to it, simply spawns it. It would only block if fork blocks... and even then the user would read '### VSCode main.js ###' in his console.

johnnyPescarul commented 8 years ago

I tried again to see if any processes are actually started, but no VSCode process is being started at all, when trying to start in offline mode. Unfortunately I don't have another Windows 8 machine to try and see if I can replicate the issue.

bpasero commented 8 years ago

@johnnyPescarul can you run code --version and see output?

johnnyPescarul commented 8 years ago

@bpasero it is version 1.2.0 Again, if the laptop is offline, the code --version doesn't even work (nothing is displayed).

bpasero commented 8 years ago

Wow, that seems to indicate a problem with Electron unless I am mistaken because we use Electron as node, correct @joaomoreno @Tyriar ?

Tyriar commented 8 years ago

code --version is one of the first things that is checked. Literally the CLI process parses args and checks help and version in an ELectron process where ATOM_SHELL_INTERNAL_RUN_AS_NODE=1.

Here is code.cmd:

@echo off
setlocal
set VSCODE_DEV=
set ATOM_SHELL_INTERNAL_RUN_AS_NODE=1
call "%~dp0..\@@NAME@@.exe" "%~dp0..\resources\\app\\out\\cli.js" %*
endlocal

Which calls into cli.ts:

export function main(args: string[]): TPromise<void> {
    const argv = parseArgs(args);

    if (argv.help) {
        console.log(helpMessage);
    } else if (argv.version) {
        console.log(pkg.version);
    } else ...other cases...

    return TPromise.as(null);
}

main(process.argv.slice(2))
    .then(() => process.exit(0))
    .then(null, err => {
        console.error(err.stack ? err.stack : err);
        process.exit(1);
    });
ghost commented 8 years ago

I have noticed this problem as well. Opening two visual studio code instances by running code --verbose twice has resulted in the second instance opening/starting correctly.

PHeonix25 commented 8 years ago

Can confirm this exact same behaviour when running on Windows 10. Putting my laptop in flight mode (as I was on a plane) meant that none of the processes were able to spawn. This means the issue is easily reproducible for me.

Running code --version or code --help while offline returns immediately without any processes spawning: image

Running either command as soon as I was tethered back on solid ground was fine: image

bpasero commented 8 years ago

Can you try to see if a bare Electron app starts at least? Try with:

PHeonix25 commented 8 years ago

I can confirm the same behaviour with the Electron app itself; both versions exhibited the same behaviour.

For reference, I downloaded the following two packages and just tried running electron.exe from a PS window (most similar example I could make to the reported behaviour above):

Thanks for helping me/us narrow it down so quickly! Shall we make an issue on electron? I couldn't find anything in their issues list so far. UPDATE: I found the following issue on the Atom Shell forum.

For the moment, might it be worth adding something to the VS Code project documentation so that we don't surprise/disappoint more people trying to use the editor without an internet connection?

bpasero commented 8 years ago

@PHeonix25 please report this to https://github.com/atom/electron

PHeonix25 commented 8 years ago

Will do, thanks @bpasero. FYI - after finding this issue on the Atom Shell feedback forum, I also tried to implement one of the final proposed solutions: add the executable to the Windows Firewall rules - with no success - it's definitely a problem with electron. :cry:

bpasero commented 8 years ago

Thanks for filing it 👍

johnnyPescarul commented 8 years ago

Finally, somebody was able to replicate the issue :) Thanks @PHeonix25 . For me this was a very big issue, because I had set-up a travel laptop with my dev environment, tested everything and was relying on doing a lot of offline work on that laptop. Unfortunately when I tried to use it offline I realized it was not working, and at that time I had no option to connect and download a different IDE. Thanks anyway for the great work on VSC.

PHeonix25 commented 8 years ago

No worries @johnnyPescarul - keep an eye on the other issue for updates. I was in the same situation - and it was a very frustrating 14hr flight.

sanjayojha commented 8 years ago

I can also confirm this bug. I opened same issue here (https://github.com/Microsoft/vscode/issues/11228). Sorry for this i was not aware of this.

VSCode Version: Code 1.4.0 (6276dcb, 2016-08-04T16:45:31.680Z)
OS Version: Windows_NT ia32 10.0.10586
ghost commented 8 years ago

Version 1.6.1 takes very long time to start up. I guess the reasons are:

After I turned off Internet connection, killed the process, then started it again, it started immediately.

It would be great if you add new flag --offline, to run VSC in offline mode.

bpasero commented 7 years ago

Does not reproduce for me anymore using 1.8. Please comment if you still see it.

bpasero commented 7 years ago

Still seems to happen on Windows 2012 Server at least.

hhhhidk commented 7 years ago

I'm also having this issue but i'm using a windows 7 machine. Nothing appeared when i try to launch vscode while offline (tried both 1.8 and 1.9). But then i tried to run using cygwin, still nothing, but it prints out this message.

$ code
C:\Program Files\Microsoft VS Code\Code.exe: c:\jenkins\workspace\electron-win-ia32\vendor\node\src\cares_wrap.cc:1327: Assertion `(r) == (0)' failed.

I hope this could be a help somehow.

BSykesUSCG commented 7 years ago

I was digging back into #18507 today and stumbled across #17097 which also applies to my scenario (specifically single core VM). Its possible it may not be the fact that we are offline but rather the VM?

BSykesUSCG commented 7 years ago

CONFIRMED SOLUTION -- We added another core to our existing VM and the CPU issues disappeared for both Visual Studio Code and Atom (Both of which rely on Electron). At this point I believe this is actually electron issue electron/electron#7839.

ejamshidiasl commented 7 years ago

I found a way.make ad-hoc network with this code: Netsh wlan set hostednetwork mode=allow ssid=myexssid key=myexpass and start network with Netsh wlan start hostednetwork then open VSCode.after open VSCode you can close connection with this code Netsh wlan stop hostednetwork

dongxiansuixin commented 7 years ago

Sorry to bother but I have to reproduce 'cause I have a lot of time without internet connection. I have no choice but uninstall VSC and I don't know whether I'll restart using it even though the bug has fixed. This is my issue #23519.

glennsarti commented 7 years ago

I also have the same issue. Repro information Procmon shows code.exe is running, it's accessing a lot of networking reg keys and files.

Like the first post, running code --version shows nothing if not connected to the internet.

I do have additional Network interfaces due to having HyperV internal networks so that may be confusing Code...

C:\Source> code --version
1.11.1
d9484d12b38879b7f4cdd1150efeb2fd2c1fbf39

Windows 10 (14393.953)
bpasero commented 7 years ago

@glennsarti does it still happen with 1.12?

glennsarti commented 7 years ago

@bpasero I'll try first thing tomorrow morning.

glennsarti commented 7 years ago

@bpasero Apologies for not updating this issue. Confirmed this issue is not present on 1.12.0. Just tested again on 1.12.2 and all good.

I'm happy to close this issue.

benmccallum commented 7 years ago

Sorry to report but I'm getting this on 1.13.1 (a higher version than mentioned as fixed above). Literally can toggle flight mode and repro. image

andreagrandi commented 7 years ago

Hi everyone,

I'm afraid but I can confirm that even the latest version of VSCode has this problem. I noticed/reproduced today while I was tempting to code during a flight:

➜  bin ./code --verbose
[72917:0708/140203.395630:WARNING:dns_config_service_posix.cc(152)] dns_config has unhandled options!
[main 14:02:03] Sending env to running instance...
[main 14:02:03] Sent env to running instance. Terminating...
andreagrandi commented 7 years ago

I must add that after this happened, now I'm connected to Internet and the application keeps crashing. I've made sure any instance had been killed from "Activity Monitor" under OSX. What else should I try?

abh1kudo commented 7 years ago

The same issue is also occurring on my vs code version 1.15 os: windows 10

image

seangenabe commented 7 years ago

Getting this too on the latest Code and Atom. Must be an Electron issue.

II-Matto commented 7 years ago

Has this problem been resolved? It happened on my laptop with win10 and the latest vscode1.17.0 (both x64) a few days ago. I am finally able to start vscode when I have internet connection today.

abh1kudo commented 7 years ago

I can confirm that the issue has been resolved immediately after the 1.17.0 update on my windows 10 laptop. Thank You to the Developer for resolving the issue :)

II-Matto commented 7 years ago

@abhikudo Hi, I just tried to start VSCode offline, and it still failed. It started normally when I reconnected to the Internet. Can you help me with this? My VSCode version is indeed 1.17.0. See the following two images for my VSCode and system details (The OS is Windows 10 home Edition). image image

bpasero commented 6 years ago

This seems to happen again...

bpasero commented 6 years ago

I tried to reproduce this on my Surface Book when I enable flight mode and I cannot. So it is not just the fact that there is no internet connection, there must be more. I still have not figured out what this "more" actually could be...

DickvdBrink commented 6 years ago

I had a similar issue with my own electron app; when I didn't have an internet connection but did had a connected adapter (I had some bridged and some virtual network adapters) it didn't really work.

Maybe some can confirm they have virtual network adapters? Might be an Hyper-V one, Virtual-Box or just some loopback adapter?

vishal4799 commented 6 years ago

How to run VS code in offline mode when i am connected to internet? When i open git cloned folder in VS code, I dont want VS code to connect git server.

xakepbean commented 6 years ago

I encountered the same problem, the first suggested that dns not equipped, I configured dns, even the clues are gone, cpu consistent 99%

one: 20171205142858

two: 28

siji147 commented 6 years ago

I'm currently having the same issue. VSC fails to launch without internet. My version is 1.19.1 so it's the latest as at the time of writing. I even updated to 1.20.0 - Insider but it was the same thing.

Marsh93 commented 6 years ago

I had the same problem I could not boot vscode without internet, I use windows 10, it came out to update actualize windows and then I could run vscode without internet, now the problem has returned, I do not know what to do, if someone has the solution could help us There are many of us who have this problem.