Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,5 @@
"type": "git",
"url": "https://github.com/LimeChain/gimlet.git"
},
"dependencies": {
"systeminformation": "^5.31.6"
}
"dependencies": {}
}
15 changes: 7 additions & 8 deletions src/managers/portManager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const crypto = require('crypto');
const si = require('systeminformation');
const net = require('net');
const vscode = require('vscode');
const { debugConfigManager } = require('./debugConfigManager');
const { getDebuggerSession } = require('./sessionManager');
Expand Down Expand Up @@ -65,13 +65,12 @@ class PortManager {
}

async isPortOpen(port) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is used to wait for a fresh gdbstub listener while the current LLDB connection may still be established on the port. A bind probe can return EADDRINUSE for the established connection even when no listener exists, which will resolve the outer loop to start another debug session immediately.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't consider that, I was mainly focused on the optimization aspect, didn't take note that the same check served for fresh listeners.

Thanks, I guess you can close now.

try {
const connections = await si.networkConnections();
return connections.some(c => c.localPort === String(port) && (c.protocol === 'tcp4' || c.protocol === 'tcp') && c.state === 'LISTEN');
} catch (err) {
log(`Port check failed: ${err.message}`);
return false;
}
return new Promise((resolve) => {
const server = net.createServer();
server.once('error', (err) => resolve(err.code === 'EADDRINUSE'));
server.once('listening', () => server.close(() => resolve(false)));
server.listen(port, '127.0.0.1');
});
}

async listenAndStartDebugForPort(port) {
Expand Down