Repository navigation
fix(next-plugin): keep each coordinator's port and recover from restarts - #917
Merged
Merged
Conversation
The Turbopack source and CSS loaders each had their own coordinator HTTP client. The CSS loader cached one port for every port file, so a second app in the same process fetched the first app's CSS. A loader whose coordinator restarted failed the build instead of reading the port the new coordinator published. Neither client set a timeout, so a coordinator that accepted a request and then stopped answering hung the build forever. A port file read while it was being written was parsed as `NaN` and cached. Both loaders now share one client that: - caches the port per port file and ignores content that is not a valid port until the file is complete (an error names the file if it never is); - on a refused connection forgets the port, reads the file again, and sends the request once to a new port, reporting the coordinator as unreachable if the file still names the same one; - fails a request that gets no response for 300s, well above the longest wait the coordinator makes on purpose. Refs #686 (NXT-04, NXT-05, NXT-06), #694 (NXT-16) 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
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
css-loader.ts now reaches the coordinator through callCoordinator (#917); keep this branch's status-plus-reason error message on top of reply.body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
coordinator.ts: main's Turbopack theme reload (#944) kept its watch in module globals; it now lives in each app's CoordinatorState, created from options.theme, and refreshTheme(state) runs before each /css and /extract of that app. The reload registers the theme through the app's session compiler, so one app's devup.json never reaches another's engine. close() writes the pending files synchronously (#917) before releasing the app, and resetCoordinator keeps clearing the registry instead of the removed globals. extractor/lib.rs keeps both the ExtractorCaches export and vanilla_extract_theme_import_tests. 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 NXT-04, NXT-05, NXT-06 from #686 and NXT-16 (read side) from #694. Merged the coordinator HTTP clients that the Turbopack source loader and the CSS loader each had into a single
coordinator-client.ts./csswait, defaultmaxWaitMs60 seconds).NaNas the port. Now, if it isn't an integer from 1 to 65535, it isn't cached and the existing wait (50ms × 20) continues. If there is still no valid port at the end, the error points at that file.Remaining
/healthtoken check) is not done. On Windows, renaming onto a file another process is reading can fail with EPERM. The read-side validation already guards against truncated files.New errors
Coordinator port file <file> names no valid port. Restart the dev server or build so the coordinator writes it again.Coordinator at 127.0.0.1:<port> (port file <file>) sent no response for 300s. It is stuck or another process holds the port: restart the dev server or build.Test plan
coordinator-client.test.ts(real HTTP server): per-port-file cache, POST body, following a coordinator restarted on a new port, same port refused again, new port also refused, port file gone after restart, waiting on a port file being written, out-of-range port, read failure, timeout on an unresponsive coordinator. 100% coverage ofcoordinator-client.tsloader.test.ts,css-loader.test.ts,coordinator-port.test.tspass요약
#686의 NXT-04, NXT-05, NXT-06과 #694의 NXT-16(읽는 쪽)을 고칩니다. Turbopack 소스 로더와 CSS 로더가 각자 갖던 coordinator HTTP 클라이언트를
coordinator-client.ts하나로 합쳤습니다./css대기, 기본maxWaitMs60초)보다 훨씬 깁니다.NaN을 port로 캐시했습니다. 이제 1~65535 정수가 아니면 캐시하지 않고 기존 대기(50ms × 20)를 계속합니다. 끝까지 유효한 port가 없으면 그 파일을 가리키는 오류입니다.남은 것
/health토큰 확인)은 하지 않았습니다. Windows에서 다른 프로세스가 읽는 중인 파일로 rename하면 EPERM이 날 수 있습니다. 읽는 쪽 검증으로 잘린 파일은 막힙니다.새로 생기는 오류
Coordinator port file <file> names no valid port. Restart the dev server or build so the coordinator writes it again.Coordinator at 127.0.0.1:<port> (port file <file>) sent no response for 300s. It is stuck or another process holds the port: restart the dev server or build.테스트 계획
coordinator-client.test.ts(실제 HTTP 서버): port file별 캐시, POST body, 새 port로 재시작한 coordinator 따라가기, 같은 port 재거부, 새 port도 거부, 재시작 후 port file 사라짐, 쓰는 중인 port file 대기, 범위 밖 port, 읽기 실패, 응답 없는 coordinator timeout.coordinator-client.ts커버리지 100%loader.test.ts,css-loader.test.ts,coordinator-port.test.ts통과Refs #686
Refs #694
🤖 Generated with Claude Code