diff --git a/client/src/engine/jobs.ts b/client/src/engine/jobs.ts index 8b3f06f..066e5bc 100644 --- a/client/src/engine/jobs.ts +++ b/client/src/engine/jobs.ts @@ -47,7 +47,6 @@ export enum Request { lspWorkspaceSymbols = 'lsp/workspaceSymbols', lspShowAst = 'lsp/showAst', - internalRestart = 'ext/restart', // Internal Extension Request internalReady = 'ext/ready', // Internal Extension Request internalMessage = 'ext/message', // Internal Extension Request internalError = 'ext/error', // Internal Extension Request diff --git a/client/src/extension.ts b/client/src/extension.ts index 89087e9..85416e9 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -270,8 +270,6 @@ async function startSession( client.onNotification(jobs.Request.internalDiagnostics, handlePrintDiagnostics) - client.onNotification(jobs.Request.internalRestart, makeHandleRestartClient(context)) - client.onNotification(jobs.Request.internalMessage, vscode.window.showInformationMessage) client.onNotification(jobs.Request.internalError, handleError) diff --git a/server/src/engine/jobs.ts b/server/src/engine/jobs.ts index 67a3b03..0dccef9 100644 --- a/server/src/engine/jobs.ts +++ b/server/src/engine/jobs.ts @@ -50,7 +50,6 @@ export enum Request { lspSemanticTokens = 'lsp/semanticTokens', lspShowAst = 'lsp/showAst', - internalRestart = 'ext/restart', // Internal Extension Request internalReady = 'ext/ready', // Internal Extension Request internalMessage = 'ext/message', // Internal Extension Request internalError = 'ext/error', // Internal Extension Request diff --git a/server/src/engine/socket.ts b/server/src/engine/socket.ts index 52ac414..8cd81f4 100644 --- a/server/src/engine/socket.ts +++ b/server/src/engine/socket.ts @@ -23,8 +23,6 @@ import { USER_MESSAGE } from '../util/userMessages' import { StatusCode } from '../util/statusCodes' import ReconnectingWebSocket from 'reconnecting-websocket' import WebSocket from 'ws' -import { getPortPromise } from 'portfinder' -import { get } from 'http' let webSocket: ReconnectingWebSocket let webSocketOpen = false @@ -106,7 +104,7 @@ export function initialiseSocket({ uri, onOpen, onClose }: InitialiseSocketInput if (lastManualStopTimestamp + 15000 < Date.now()) { // This happens when the connections breaks unintentionally - handleLostConnection() + console.log(USER_MESSAGE.CONNECTION_LOST()) return } @@ -187,29 +185,6 @@ function handleResponse(flixResponse: FlixResponse, job: jobs.EnqueuedJob) { eventEmitter.emit('any') } -/** - * Handle a connection loss. - * This might be temporary, as the websocket will automatically try to reconnect. - */ -async function handleLostConnection() { - console.log(USER_MESSAGE.CONNECTION_LOST()) - - const port = parseInt(webSocket.url.split(':')[2]) - if (await portIsFree(port)) { - // The port has become free, meaning the server is not running. - // Restart the server. - sendNotification(jobs.Request.internalRestart) - } -} - -/** - * Determine whether or not the given port is free. - */ -async function portIsFree(port: number) { - const freePort = await getPortPromise({ port }) - return freePort === port -} - /** * The number of sent requests which have not yet received a response. */