Repository navigation
Conversation
A process that finds another live coordinator on its distDir already takes its own coordinator.<pid>.port, but it still wrote the same sheet.json, classMap.json, fileMap.json, canonicalMap.json and setup.bin. A next dev and a next build in one directory therefore overwrote each other's state, and the next restore imported a mix of both. Such a process now writes its state to distDir/state.<pid>. It still restores from the shared distDir files, which are what Turbopack's persistent cache was built against. The process holding the shared port file keeps distDir, so the single-process case is unchanged. Startup removes the state.<pid> directories of processes that have exited. Refs #694 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This was referenced Nov 15, 2026
#918 restores session state through restoreSessionState; keep calling it with the shared distDir files, so a process with its own state dir still starts from what the cache was built against. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the remaining part of audit item NXT-08 (P1, NONDET). On main, the port file is already separated: if another live process holds
distDir/coordinator.port,coordinator.<pid>.portis used. But the state files (sheet.json,classMap.json,fileMap.json,canonicalMap.json,setup.bin) still used the same paths. Sonext devandnext buildin the same directory overwrote each other's state, and the next restore could pick up a state mixing two builds.resolveStateDir(distDir, portFile)tocoordinator-port.tsdistDir, as beforedistDir/state.<pid>state.<pid>(coordinator writes, loader options, canonical map, production setup handoff).distDirfiles, because the Turbopack persistent cache was built against that state.removeStaleStateDirs(distDir)removesstate.<pid>directories of exited processes (if locked on Windows, it retries on the next start).distDir, so behavior and loader option keys in the common case do not change.cssDir(devup-ui*.css) is still shared. In Turbopack coordinator mode, CSS content comes from each coordinator's/css, and the files on disk only serve as invalidation triggers and placeholders, so they do not pollute each other's CSS. However, the other process's writes can cause unnecessary recompiles.Overlap with other PRs
fix/next-turbo-setup) covers "restore session state whole" (making sheet / class / file map restore transactional). This PR changes the read paths of the same restore block tojoin(distDir, ...), so a conflict is expected. Whichever is merged later just needs to keep the rule "read from the shared distDir, write to stateDir".plugin.ts, so textual conflicts may occur.Test plan
bun test --coverage(plugin, coordinator-port, coordinator, loader, css-loader):plugin.ts,coordinator-port.ts100% lines / functionsdistDir, own port →state.<pid>distDiris missing orrmSyncfailsstate.<pid>, restores from the shared state, and coordinator / loader / canonical map / setup handoff write tostate.<pid>bunx tsc --noEmit -p packages/next-pluginbunx prettier --single-quote --no-semi --check(changed files)plugin.test.ts(native engine /seedFileMap) fail the same way on main as well, due to stale WASM / native builds.요약
감사 항목 NXT-08 (P1, NONDET)의 남은 부분 수정입니다. main에서 port 파일은 이미 분리됩니다: 다른 live 프로세스가
distDir/coordinator.port를 갖고 있으면coordinator.<pid>.port를 씁니다. 하지만 상태 파일(sheet.json,classMap.json,fileMap.json,canonicalMap.json,setup.bin)은 여전히 같은 경로를 썼습니다. 그래서 같은 디렉터리의next dev와next build가 서로의 상태를 덮어쓰고, 다음 restore가 두 빌드가 섞인 상태를 가져올 수 있었습니다.coordinator-port.ts에resolveStateDir(distDir, portFile)추가distDirdistDir/state.<pid>state.<pid>에만 씁니다 (코디네이터 쓰기, loader 옵션, canonical map, production setup handoff).distDir파일에서 읽습니다. Turbopack persistent cache가 그 상태를 기준으로 만들어졌기 때문입니다.removeStaleStateDirs(distDir)가 종료된 프로세스의state.<pid>디렉터리를 지웁니다 (Windows에서 잠겨 있으면 다음 시작에서 다시 시도).distDir을 쓰므로 일반적인 경우의 동작과 loader 옵션 키는 바뀌지 않습니다.cssDir(devup-ui*.css)는 여전히 공유합니다. Turbopack 코디네이터 모드에서 CSS 내용은 각 코디네이터의/css에서 오고, 디스크 파일은 무효화 트리거와 placeholder 역할만 하므로 서로의 CSS를 오염시키지 않습니다. 대신 상대 프로세스의 쓰기가 불필요한 재컴파일을 일으킬 수는 있습니다.다른 PR과의 겹침
fix/next-turbo-setup)이 "restore session state whole" (sheet / class / file map 복원 트랜잭션화)을 다룹니다. 이 PR은 같은 복원 블록의 읽기 경로를join(distDir, ...)로 바꾸므로 충돌이 예상됩니다. 둘 중 나중에 머지되는 쪽에서 "공유 distDir에서 읽고, stateDir에 쓴다"는 규칙을 유지하면 됩니다.plugin.ts의 setup 근처를 수정하므로 텍스트 충돌이 날 수 있습니다.테스트 계획
bun test --coverage(plugin, coordinator-port, coordinator, loader, css-loader):plugin.ts,coordinator-port.ts100% lines / functionsdistDir, 자기 port면state.<pid>distDir이 없거나rmSync가 실패해도 throw하지 않음state.<pid>생성, 공유 상태에서 restore, 코디네이터 / loader / canonical map / setup handoff는state.<pid>로 씀bunx tsc --noEmit -p packages/next-pluginbunx prettier --single-quote --no-semi --check(변경 파일)plugin.test.ts의 3개 테스트(native 엔진 /seedFileMap)는 오래된 WASM / native 빌드 때문에 main에서도 동일하게 실패합니다.Refs #694
🤖 Generated with Claude Code