Repository navigation
fix(cli): isolate concurrent session shares - #57
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Fixes a concurrency bug where overlapping session shares overwrote each other's temp files by giving each invocation its own temp directory, with a test verifying isolation.
Re-trigger cubic
a2138e4 to
9fa58de
Compare
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
Both exports were written to fixed paths in os.tmpdir(), so a second /share overwrote the first one's session.jsonl and session.html, and whichever finished first deleted the file the other was still uploading — producing a share of the wrong session, or a failed upload. Give each invocation its own mkdtemp directory and remove only that. A directory that cannot be created still surfaces the usual export error instead of rejecting out of shareSession. Ported from upstream pi.
9fa58de to
13586e1
Compare
|
Addressed — |
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Fixes a concurrency bug in session sharing by isolating each share's temp directory, with a deterministic test verifying isolation.
Re-trigger cubic
Summary
shareSession()wrote both exports to fixed paths inos.tmpdir()—session.jsonlandsession.html. Two/shareinvocations overlapping (two sessions, or one started before the previous upload finished) meant the second clobbered the first's export, and whichever finished first deleted the file the other was still uploading. The result was a share containing the wrong session, or a failed upload.Each invocation now gets its own
mkdtempSyncdirectory and thefinallyblock removes only that directory. Creating the directory is guarded, so an unwritableos.tmpdir()shows the sameFailed to export sessionmessage the old code produced rather than rejecting out ofshareSession.Ported from upstream pi, with the temp prefix renamed to
knightcode-share-.Testing
test/session-share.test.tsinterleaves two shares deterministically and asserts each upload carries its own session's content.main(expected [ 'B' ] to deeply equal [ 'A', 'B' ]) and passes with the fix.bun run check-typesclean.