Skip to content

test: ensure middleware after waits for response#2

Draft
vercel-gh-bot-2[bot] wants to merge 2 commits into
next-maintainer-agent/base-163e45e401dffrom
next-maintainer-agent/issue-74941-47e5ca36e89d
Draft

test: ensure middleware after waits for response#2
vercel-gh-bot-2[bot] wants to merge 2 commits into
next-maintainer-agent/base-163e45e401dffrom
next-maintainer-agent/issue-74941-47e5ca36e89d

Conversation

@vercel-gh-bot-2

Copy link
Copy Markdown

What

Adds regression coverage for middleware after() callback timing. The existing delayed-response fixture now schedules an after() 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 for after() 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.js 15.1.4) and records verdict still_reproduces: both 15.1.4 and frozen canary 16.3.0-canary.90 ran the middleware callback before page rendering started. Running its persisted node verify.mjs contract observed:

Middleware Timing - Start -> Middleware Timing - End -> Page Timing - Start -> Page Timing - End
SYMPTOM PRESENT: middleware after() completed before page rendering began

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):

Expected value: not {"source": "[middleware] /delay"}
Received array: [{"source": "[middleware] /delay"}]

Formatting, ESLint, and git diff --check completed successfully. CI is expected to fail at this new assertion until the middleware after() timing bug is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants