Skip to content

Commit 45aef71

Browse files
committed
Make sure heartbeat isActive resolves
This does not seem to actually cause an issue (not resolving ends up with the same behavior as resolving with false) but I am not sure if the hanging promises would be a memory leak so seems best to fix.
1 parent 6d6c5e1 commit 45aef71

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/node/routes/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ import { CodeServerRouteWrapper } from "./vscode"
3333
export const register = async (app: App, args: DefaultedArgs): Promise<Disposable["dispose"]> => {
3434
const heart = new Heart(path.join(paths.data, "heartbeat"), async () => {
3535
return new Promise((resolve, reject) => {
36+
// getConnections appears to not call the callback when there are no more
37+
// connections. Feels like it must be a bug? For now add a timer to make
38+
// sure we eventually resolve.
39+
const timer = setTimeout(() => {
40+
logger.debug("Node failed to respond with connections; assuming zero")
41+
resolve(false)
42+
}, 5000)
3643
app.server.getConnections((error, count) => {
44+
clearTimeout(timer)
3745
if (error) {
3846
return reject(error)
3947
}

0 commit comments

Comments
 (0)