Skip to content

Commit

Permalink
chore: never relaunch compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
sockmaster27 committed Aug 23, 2024
1 parent cbea5d0 commit 66f493c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 30 deletions.
1 change: 0 additions & 1 deletion client/src/engine/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion server/src/engine/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 1 addition & 26 deletions server/src/engine/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 66f493c

Please sign in to comment.