Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Session migration can truncate history if rewrite is interrupted

Aperta
#145 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, cli, tooling

Direzione di ricerca

The issue is in packages/coding-agent/src/core/session-manager.ts around line 980. Look at the _rewriteFile() method and the openSync call with mode 'w'. Understand the session migration flow in SessionManager._setSessionFile(). Research Node.js atomic write patterns, like the linked write-file-atomic library. A fix involves writing to a temporary file first, then renaming it over the original on success. Test by creating a v1/v2 session file and simulating an interruption during migration.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

untriaged
What happened?

Opening a v1/v2 session migrates it and rewrites the same JSONL file. _rewriteFile() opens the original with "w", truncating it before writing entries back. If the process or write fails during migration, previously saved history can be left truncated. This is the path in SessionManager._setSessionFile() on current main.

Steps to reproduce
  1. Open an existing v1/v2 session with enough entries to make migration observable.
  2. Interrupt the process after _rewriteFile() opens the original file and before it finishes writing.
  3. Reopen the session: the original file contains only the prefix written before interruption.

This follows directly from openSync(this.sessionFile, "w") in session-manager.ts. I have not observed a production incident.

Expected behavior

Build the complete migrated file in a unique sibling temporary file, flush and close it, then rename it over the original. Keep the original on any error. Node's atomic-write implementation uses this pattern.

Version

main @ cb5fc1456d49d49c62e072bfed2926220083214e

AI-assisted report; source path checked against the stated commit.

Lingua principale
TypeScript
Stelle
471
Fork
42
Merge medio
21h 12m
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stepfun-ai/Step-Code

Tutte le issue di stepfun-ai/Step-Code

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.