Skip to content
Open
Changes from all 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: 4 additions & 1 deletion solara/server/kernel_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ def initialize_virtual_kernel(session_id: str, kernel_id: str, websocket: websoc
context = contexts[kernel_id]
if context.session_id != session_id:
logger.critical("Session id mismatch when reusing kernel (hack attempt?): %s != %s", context.session_id, session_id)
websocket.send_text("Session id mismatch when reusing kernel (hack attempt?)")
# Close the websocket cleanly instead of sending plain text.
# The JupyterLab kernel protocol expects all messages to be JSON,
# so sending plain text causes a parse error on the client.
websocket.close()
# to avoid very fast reconnects (we are in a thread anyway)
time.sleep(0.5)
raise ValueError("Session id mismatch")
Expand Down