rsnext/packages/next
Zack Tanner 48a566bc4f
fix waitUntil handling in pipeToNodeResponse (#58744)
### What?
Calls to `revalidateTag` when using the data cache would sometimes be ignored. This would result in stale data being displayed even after manually triggering a revalidation. 

### Why?
Revalidation calls are pushed onto a `pendingRevalidates` array and, in the case of a route handler, are awaited [here](8b11264ea9/packages/next/src/server/send-response.ts (L53-L55)).  

Previously this took place as part of the former `pipeReadable` implementation ([ref](57bb52d37d/packages/next/src/server/send-response.ts (L49))) which awaited the promise before calling res.end ([ref](57bb52d37d/packages/next/src/server/pipe-readable.ts (L99-L105))). There was a subtle change in behavior here in a recent refactor that seems to cause a race between awaiting the promise and ending the response, which results in this unpredictable behavior.

### How?
This applies similar logic that used to be in the `pipeReadable` function to the new `pipeToNodeResponse` function. Namely, we plumb `waitUntil` into the writeable stream close handler and await it before calling `res.end()`.

This is a very difficult edge case to test, and as such resorted to rigorous manual testing when deployed to an environment that uses the data cache. 

Fixes #52962
Fixes #57632
2023-11-22 02:37:35 +00:00
..
compat
experimental/testmode Concept: test mode for Playwright and similar integration tools (#52520) 2023-08-14 18:45:50 +00:00
font
image-types
legacy
navigation-types/compat Update useParams typing to assume a given shape (#55126) 2023-09-14 20:20:42 +00:00
src fix waitUntil handling in pipeToNodeResponse (#58744) 2023-11-22 02:37:35 +00:00
types onHeaders updates for App Pages (#58410) 2023-11-16 05:44:58 +00:00
amp.d.ts
amp.js
app.d.ts
app.js
babel.d.ts
babel.js
cache.d.ts cache: add unstable_noStore API (#56930) 2023-10-17 14:52:46 +00:00
cache.js chore: fix a typo (#57272) 2023-10-23 17:10:35 +00:00
client.d.ts
client.js
config.d.ts server: bundle vendored react (#55362) 2023-09-15 19:49:39 +00:00
config.js server: bundle vendored react (#55362) 2023-09-15 19:49:39 +00:00
constants.d.ts
constants.js
document.d.ts
document.js
dynamic.d.ts
dynamic.js
error.d.ts
error.js
head.d.ts
head.js
headers.d.ts
headers.js
image.d.ts
image.js
index.d.ts perf: replace zod with superstruct (#56083) 2023-09-28 11:05:36 +02:00
jest.d.ts
jest.js
license.md
link.d.ts
link.js
navigation.d.ts
navigation.js
og.d.ts Move ImageResponse to next/og (#56662) 2023-10-19 14:26:48 +00:00
og.js Move ImageResponse to next/og (#56662) 2023-10-19 14:26:48 +00:00
package.json v14.0.4-canary.9 2023-11-22 02:11:25 +00:00
README.md
router.d.ts
router.js
script.d.ts
script.js
server.d.ts
server.js
taskfile-ncc.js
taskfile-swc.js revert "React Aliases (#57283)" (#57299) 2023-10-23 16:59:55 -07:00
taskfile-watch.js
taskfile-webpack.js Unsilence Taskr Webpack errors (#56542) 2023-10-06 23:38:18 +00:00
taskfile.js Get rid of semver from the server bundle (#57321) 2023-10-24 18:05:56 +00:00
tsconfig.json enable verbatimModuleSyntax to make type imports/exports explicit (#56551) 2023-10-07 15:09:54 +00:00
web-vitals.d.ts
web-vitals.js
webpack.config.js Fix Regex (#57461) 2023-10-26 04:07:13 +00:00

Next.js

Getting Started

Visit https://nextjs.org/learn to get started with Next.js.

Documentation

Visit https://nextjs.org/docs to view the full documentation.

Who is using Next.js?

Next.js is used by the world's leading companies. Check out the Next.js Showcase to learn more.

Community

The Next.js community can be found on GitHub Discussions, where you can ask questions, voice ideas, and share your projects.

To chat with other community members you can join the Next.js Discord.

Our Code of Conduct applies to all Next.js community channels.

Contributing

Please see our contributing.md.

Good First Issues

We have a list of good first issues that contain bugs that have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.

Authors

Security

If you believe you have found a security vulnerability in Next.js, we encourage you to responsibly disclose this and not open a public issue. We will investigate all legitimate reports. Email security@vercel.com to disclose any security vulnerabilities.

https://vercel.com/security