Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]:299 - uncaught exception session with id 'Not Found' after dele… #313

Merged
merged 6 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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: 15 additions & 6 deletions packages/api/server/ws.mts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ async function cellExec(payload: CellExecPayloadType) {
const session = await findSession(payload.sessionId);
const cell = findCell(session, payload.cellId);

console.log('inside cellExec');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this?

if (!cell || cell.type !== 'code') {
console.error(`Cannot execute cell with id ${payload.cellId}; cell not found.`);
return;
Expand Down Expand Up @@ -616,11 +617,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 +645,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