test: ensure middleware after waits for response#2
Draft
vercel-gh-bot-2[bot] wants to merge 2 commits into
Draft
Conversation
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.
What
Adds regression coverage for middleware
after()callback timing. The existing delayed-response fixture now schedules anafter()callback in middleware and asserts that it does not run while the page response is blocked, then asserts that it does run after the response finishes.Issue: vercel#74941
Why this suite
This is grafted into
test/e2e/app-dir/next-after-app, the existing end-to-end suite forafter()across pages, route handlers, actions, and middleware. It reuses that suite's proxy-controlled delayed response, structured CLI logs,retry()assertions, Node.js/Edge page-runtime matrix, and dev/start coverage rather than adding a parallel fixture.Verification
Stored verification vercel#1135 for reproduction vercel#1043 pins reporter commit
2175ff2c603174e7f70d86249ec0adf1221e6968(reported Next.js15.1.4) and records verdictstill_reproduces: both15.1.4and frozen canary16.3.0-canary.90ran the middleware callback before page rendering started. Running its persistednode verify.mjscontract observed:The translated test was run on untouched canary
163e45e401dfafb6c9121610ccec24967cc3402a(16.3.0-canary.90) with each focused command once:pnpm test-dev-turbo test/e2e/app-dir/next-after-app/index.test.ts -t "only runs callbacks after the response is fully sent"pnpm test-start-turbo test/e2e/app-dir/next-after-app/index.test.ts -t "only runs callbacks after the response is fully sent"pnpm test-dev-webpack test/e2e/app-dir/next-after-app/index.test.ts -t "only runs callbacks after the response is fully sent"pnpm test-start-webpack test/e2e/app-dir/next-after-app/index.test.ts -t "only runs callbacks after the response is fully sent"All four commands failed for the expected regression-sensitive reason in both the Node.js and Edge page-runtime cases (
2 failed, 32 skipped):Formatting, ESLint, and
git diff --checkcompleted successfully. CI is expected to fail at this new assertion until the middlewareafter()timing bug is fixed.