[pull] canary from vercel:canary#1134
Merged
Merged
Conversation
[flakiness metrics](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22app%20dir%20-%20metadata%20static%20routes%20cache%20should%20generate%20different%20content%20after%20replace%20the%20static%20metadata%20file%22%20%40test.type%3A%22nextjs%22%20%40test.status%3A%28fail%20OR%20pass%29%20%40git.branch%3Acanary&agg_m=count&agg_m_source=base&agg_t=count&fromUser=false&index=citest&start=1780774829532&end=1781379629532&paused=false) <img width="423" height="173" alt="Screenshot 2026-06-13 at 21 41 05" src="https://github.com/user-attachments/assets/d9888a77-db05-4ab5-89e3-97f01b9d7353" /> This test replaces the static favicon and Open Graph image and rebuilds to verify the served content changes, so it needs one production build with the original files and another with the replacements. Running both `next.start()` cycles in a single test case put two full builds under the 60s per-test budget, which is easy to exceed on slower CI runners, where the second build most often stalls while collecting build traces. We move the first build, start, and baseline measurement into `beforeAll`, where it can use the longer setup-hook budget, and leave the test body responsible only for the second build. Keeping the build out of the test body also makes it idempotent, so a retry recomputes the new hashes against the baseline that `beforeAll` captures once.
When a `next start` test exceeds the per-test timeout while `next build` is still running, the build process is left running and tracked by the next instance, because the build phase of `NextStartInstance.start()` clears `childProcess` only when the process exits. `jest.retryTimes` then re-runs the test body in the same process, and `start()` immediately throws `next already started`, which masks the original timeout. `NextStartInstance` now tracks whether a build or a server currently owns the child process. When `start()` finds a leftover `next build` process from an interrupted attempt, it stops that process and continues instead of throwing, so the retry can start from a clean state. The `next already started` guard is preserved for the case where a server is genuinely already running.
**Ignore whitespace changes when viewing the diff** This fixes some of the failures (particularly the ones where a 500 returned from an App API route showed up as status:200 in OTEL). But the newly added tests have more failures that I skipped for now 1. Missing `setStatus` call 2. Attribute handling was too early, before `sendResponse` was called: https://github.com/vercel/next.js/blob/6f4d94ac889db3d23a77847ec4f3a9dadf9dd775/packages/next/src/build/templates/app-route.ts#L289-L296 ```js return routeModule.handle(nextReq, context).finally(() => { // <-- handle() returns the response object from the user code if (!span) return span.setAttributes({ 'http.status_code': res.statusCode, // <---------- this is using some default response object, not what handle() returned 'next.rsc': false, }) ```
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )