hangxingliu / vscode-coding-tracker

:clock10: A coding activities tracker(time, file, type)
GNU General Public License v3.0
171 stars 34 forks source link

Race condition when opening multiple windows #29

Open atombender opened 5 years ago

atombender commented 5 years ago

If you run multiple VSCode windows, this extension seems to sometimes want to start multiple servers:

[LocalMode]: try to kill old tracking server...
[LocalMode]: there are no old tracking server, just opening a new local server...
[Launch]: Local server launching...
[Launched]: Local server has launching!
15:42:41 Debug mode be turned on!

[Error]: events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE 127.0.0.1:10345
    at Server.setupListenHandle [as _listen2] (net.js:1286:14)
    at listenInCluster (net.js:1334:12)
    at doListen (net.js:1460:7)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)
Emitted 'error' event at:
    at emitErrorNT (net.js:1313:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)

[Error]: local server exit with code 1!(have you launch another local sever?)
[Exit] exit code: 1

It should detect EADDRINUSE as a non-error, since it means the server is already running, or somehow keep better track of the background process. In my case, it happens pretty consistently when starting up VSCode (as it restores the windows I previously had open).

hangxingliu commented 5 years ago

Yes, I met this bug. I will fix some bug and improve it in the end of this month

bernardoadc commented 5 years ago

Same here with a duplicate workspace (since the other window is independent). Now it made sense why it appears i had coded so little... lol

Is there an ID to each window? This could be used just like computer ID already is