Skip to content

Commit

Permalink
[FIX]:299 - uncaught exception session with id 'Not Found' after dele… (
Browse files Browse the repository at this point in the history
#313)

* [FIX]:299 - uncaught exception session with id 'Not Found' after deleting an srcbook

* [FIX] - uncaught exceptions that occurs after srcbook deletion

* [DEL] - previous changeset file

* [FIX] - linting issues

* [DEL] - console log from ws
  • Loading branch information
BeRecursive22 authored Sep 30, 2024
1 parent 3bd0e74 commit a063c46
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-laws-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@srcbook/api': patch
---

Fix uncaught exceptions in TsServer event handlers after srcbook deletion
21 changes: 14 additions & 7 deletions packages/api/server/ws.mts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ async function nudgeMissingDeps(wss: WebSocketServer, session: SessionType) {
async function cellExec(payload: CellExecPayloadType) {
const session = await findSession(payload.sessionId);
const cell = findCell(session, payload.cellId);

if (!cell || cell.type !== 'code') {
console.error(`Cannot execute cell with id ${payload.cellId}; cell not found.`);
return;
Expand Down Expand Up @@ -616,11 +615,15 @@ function createTsServer(session: SessionType) {

tsserver.onSemanticDiag(async (event) => {
const eventBody = event.body;
if (!eventBody) return;

// Get most recent session state
const session = await findSession(sessionId);

if (!eventBody || !session) {
let session;
try {
session = await findSession(sessionId);
} catch (e) {
const error = e as unknown as Error;
console.error(error);
return;
}

Expand All @@ -640,11 +643,15 @@ function createTsServer(session: SessionType) {

tsserver.onSuggestionDiag(async (event) => {
const eventBody = event.body;
if (!eventBody) return;

// Get most recent session state
const session = await findSession(sessionId);

if (!eventBody || !session) {
let session;
try {
session = await findSession(sessionId);
} catch (e) {
const error = e as unknown as Error;
console.error(error);
return;
}

Expand Down

0 comments on commit a063c46

Please sign in to comment.