next.js
56c71a2c - Turbopack: resolve app directory entries in a filesystem-independent order (#102186)

Commit
1 day ago
Turbopack: resolve app directory entries in a filesystem-independent order (#102186) ### What? Turbopack now resolves the files in an App Router directory in sorted order, so it no longer depends on the order the filesystem returns them in. The visible effect: when both `route.go` and `route.ts` exist in the same directory, the same handler wins on every machine. The `Conflicting App Router handlers` error is now always printed in the terminal. ### Why? This fixes the broken `canary` CI. In `test turbopack dev` and `test cache components dev`, every attempt of this test fails: - `test/e2e/app-dir/native-route-go/native-route-go.test.ts` › *reports conflicting Go and TS handlers from Rust and recovers* `get_directory_tree_internal` iterates `read_dir()` entries, which are kept in the order the OS returned them. When both route files exist, it emits the conflict issue, and then whichever file comes last becomes the route. That order depends on the filesystem: creation order on some, hash order on ext4. It changed when the CI runner image was updated. - **When `route.ts` won**, which happens locally, the request path logs the conflict. - **When `route.go` won**, which happens on the new CI image, the 500 is rendered via `findPageComponents` → `getCompilationErrors` → `WrappedBuildError`. That path deliberately doesn't log. The conflict only appeared in the HTML error page, so the test saw silent 500s. ### How? - Sort directory entries by name before resolving them. `route.go` sorts before every JS route extension, so the JS handler consistently wins and the conflict is always logged. - The test now writes `route.go` again after `route.ts`. On filesystems that list entries in creation order, that puts `route.go` last, so the test covers the order that used to fail silently. ### Verification - The strengthened test fails without the fix and passes with it, on a locally built `release-with-assertions` binding: - `pnpm test-dev-turbo test/e2e/app-dir/native-route-go/native-route-go.test.ts` (29/29) - Same test with the `test cache components dev` env vars (29/29) - `pnpm test-start-turbo test/e2e/app-dir/native-route-go/native-route-go.test.ts` (20/20) - `cargo fmt -p next-core -- --check` - `cargo clippy -p next-core -- -D warnings` Two earlier attempts on this PR did not fix the failure: reverting #101980, and pinning Go in the test jobs. <!-- NEXT_JS_LLM --> <!-- fleet c9d7aabb-a7d6-4d7e-9700-893c75966a94 --> Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Author
Parents
Loading