Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode 1.82.0 breaks VsCoq 0.3.38 #52

Closed
Som1Lse opened this issue Sep 8, 2023 · 3 comments
Closed

VSCode 1.82.0 breaks VsCoq 0.3.38 #52

Som1Lse opened this issue Sep 8, 2023 · 3 comments

Comments

@Som1Lse
Copy link

Som1Lse commented Sep 8, 2023

Specifically the update to Node.js 18.15.0 breaks the server code. Here is what I've discovered:

Here is a log from 1.81.1:
Coq Language Server: process.version: v16.17.1, process.arch: x64}
Loaded project at <FILENAME>
Updated project root to .
Coqtop binPath is:
Listening at 127.0.0.1:49891
Listening at 127.0.0.1:49892
Listening at 127.0.0.1:49893
Listening at 127.0.0.1:49894
starting coqtop
exec: coqtop -v
Listening at 127.0.0.1:49903
Listening at 127.0.0.1:49904
Listening at 127.0.0.1:49905
Listening at 127.0.0.1:49906
Detected coqtop version 8.16.1
Coqtop version parsed into semver version 8.16.1
exec: coqidetop.opt -main-channel 127.0.0.1:49904:49903 -control-channel 127.0.0.1:49905:49906 -async-proofs on -topfile <FILENAME>.v
coqtop started with pid 10048
And here is one from 1.82.0:
Coq Language Server: process.version: v16.17.1, process.arch: x64}
Loaded project at <FILENAME>
Updated project root to .
Coqtop binPath is:
Listening at 127.0.0.1:49891
Listening at 127.0.0.1:49892
Listening at 127.0.0.1:49893
Listening at 127.0.0.1:49894
starting coqtop
exec: coqtop -v
Listening at 127.0.0.1:49903
Listening at 127.0.0.1:49904
Listening at 127.0.0.1:49905
Listening at 127.0.0.1:49906
Detected coqtop version 8.16.1
Coqtop version parsed into semver version 8.16.1
exec: coqidetop.opt -main-channel 127.0.0.1:49904:49903 -control-channel 127.0.0.1:49905:49906 -async-proofs on -topfile <FILENAME>.v
coqtop started with pid 10048

As you might notice, the IP address of the server is different, : instead of 127.0.0.1.

I made various changes trying to isolate the problem.

  • Hard coding the IP address to 127.0.0.1 in setupCoqTopReadAndWritePorts wasn't enough, as coqtop wasn't able to connect to the server.
  • Removing host from startListening, fixed that issue, but the address would be reported as ::, which coqtop doesn't want to accept.
Doing both fixed the issue, ultimately landing at the following diff:
diff --git a/server/src/coqtop/CoqTop8.ts b/server/src/coqtop/CoqTop8.ts
index 31dc77e..bb6b855 100644
--- a/server/src/coqtop/CoqTop8.ts
+++ b/server/src/coqtop/CoqTop8.ts
@@ -109,11 +109,9 @@ export class CoqTop extends IdeSlave8 implements coqtop.CoqTop {
   }

   private startListening(server: net.Server) : Promise<void> {
-    const port = 0;
-    const host = 'localhost';
     return new Promise<void>((resolve,reject) => {
       server.on('error', (err) => reject(err));
-      server.listen({port: port, host: host}, () => {
+      server.listen({port: 0}, () => {
         const serverAddress = server.address() as AddressInfo;
         this.console.log(`Listening at ${serverAddress.address}:${serverAddress.port}`);
         resolve();
@@ -146,12 +144,12 @@ export class CoqTop extends IdeSlave8 implements coqtop.CoqTop {
   private async setupCoqTopReadAndWritePorts() : Promise<void> {
     await Promise.all(this.readyToListen);

-    var mainAddr = this.mainChannelServer.address() as AddressInfo;
+    var mainPort = (this.mainChannelServer.address() as AddressInfo).port;
     var mainPortW = (this.mainChannelServer2.address() as AddressInfo).port;
-    var controlAddr = this.controlChannelServer.address() as AddressInfo;
+    var controlPort = (this.controlChannelServer.address() as AddressInfo).port;
     var controlPortW = (this.controlChannelServer2.address() as AddressInfo).port;
-    var mainAddressArg = mainAddr.address + ':' + mainAddr.port + ':' + mainPortW;
-    var controlAddressArg = controlAddr.address + ':' + controlAddr.port + ':' + controlPortW;
+    var mainAddressArg = '127.0.0.1:' + mainPort + ':' + mainPortW;
+    var controlAddressArg = '127.0.0.1:' + controlPort + ':' + controlPortW;

     try {
       this.startCoqTop(this.spawnCoqTop(mainAddressArg, controlAddressArg));

I can submit a pull request if the above is good, but I would like feedback since it feels kinda ugly to hard code the address.

@4ever2
Copy link
Contributor

4ever2 commented Sep 9, 2023

I also see this problem after updating to VS Code 1.82.0
You are correct that it is due to the Node.js version upgrade. Specifically, this is caused by changes to how DNS resolution results are handled in Node.js 17.

I am not a big fan of your solution to the issue.
Ideally, Coq should be fixed to support ipv6. For compatibility with older Coq versions, the following patch should return the behavior from before VS Code 1.82.0:
4ever2/vscoq@bc3405e

@Som1Lse
Copy link
Author

Som1Lse commented Sep 9, 2023

Yeah, I had a feeling my solution was suboptimal.

@Som1Lse
Copy link
Author

Som1Lse commented Sep 14, 2023

With the 0.3.9 release I consider this solved.

@Som1Lse Som1Lse closed this as completed Sep 14, 2023
@gares gares transferred this issue from coq/vscoq Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants