Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
}
},
"version": "16.3.0-canary.4"
}
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"engines": {
"node": ">=20.9.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
"default": "./dist/parser.js"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"eslint": "9.37.0"
},
"scripts": {}
}
}
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"types": "tsc --project tsconfig.json --skipLibCheck --declaration --emitDeclarationOnly --esModuleInterop --declarationDir dist",
"prepublishOnly": "cd ../../ && turbo run build"
}
}
}
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"fontkit": "2.0.2",
"typescript": "6.0.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"scripts": {
"pack-for-isolated-tests": "pnpm pack --out ./packed.tgz"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
"@types/semver": "7.3.1",
"typescript": "6.0.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
"dotenv": "16.3.1",
"dotenv-expand": "10.0.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"scripts": {
"pack-for-isolated-tests": "pnpm pack --out ./packed.tgz"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"@playwright/test": "1.58.2",
"typescript": "6.0.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"directory": "packages/next-plugin-storybook"
},
"scripts": {}
}
}
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"devDependencies": {
"microbundle": "0.15.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"object-assign": "4.1.1",
"whatwg-fetch": "3.0.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"jest": "^29.5.0",
"ts-jest": "^29.1.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-rspack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"scripts": {
"pack-for-isolated-tests": "pnpm pack --out ./packed.tgz"
}
}
}
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
"cross-env": "6.0.3",
"wasm-pack": "0.13.1"
}
}
}
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,4 @@
"engines": {
"node": ">=20.9.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/next/src/build/templates/app-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export async function handler(
nodeNextReq,
nodeNextRes,
response,
context.renderOpts.pendingWaitUntil
pendingWaitUntil
)
return null
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"react-refresh": "0.12.0",
"webpack": "^4 || ^5"
}
}
}
2 changes: 1 addition & 1 deletion packages/third-parties/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
"next": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0-beta.0",
"react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0"
}
}
}
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/release-github-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async function createBlobForFile(token, commitSha, filePath) {
const content = await git(['show', `${commitSha}:${filePath}`], {
captureOutput: true,
encoding: null,
stripFinalNewline: false,
maxBuffer: 1024 * 1024 * 100,
})
const blob = await githubRequest(
Expand Down
17 changes: 10 additions & 7 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3342,9 +3342,6 @@ describe('app-dir static/dynamic handling', () => {
// Prime the cache.
let res = await next.fetch(path)
expect(res.status).toBe(200)

// Consume the cache, the revalidations are completed on the end of the
// stream so we need to wait for that to complete.
await res.text()

for (let i = 0; i < 6; i++) {
Expand Down Expand Up @@ -3374,6 +3371,7 @@ describe('app-dir static/dynamic handling', () => {
)
}
}
const finishedAt = Date.now()

const startedResponding = +data.start
if (Number.isNaN(startedResponding)) {
Expand All @@ -3387,12 +3385,17 @@ describe('app-dir static/dynamic handling', () => {
)
}

// We just want to ensure the response isn't blocked on revalidating the fetch.
// So we use the start time when route started processing not when we
// send off the response because that includes cold boots of the infra.
// The response must not be blocked on the 3s background revalidation:
// neither the first byte (TTFB) nor the terminating chunk (res.end).
// Using the route-start time excludes cold-boot/infra latency.
if (startedStreaming - startedResponding >= 3000) {
throw new Error(
`Response #${i} took too long to complete: ${startedStreaming - startedResponding}ms`
`Response #${i} first byte took too long: ${startedStreaming - startedResponding}ms`
)
}
if (finishedAt - startedResponding >= 3000) {
throw new Error(
`Response #${i} took too long to complete: ${finishedAt - startedResponding}ms`
)
}
}
Expand Down
19 changes: 19 additions & 0 deletions test/e2e/app-dir/use-cache-swr/app/delayed-route/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { cacheLife } from 'next/cache'
import { setTimeout } from 'timers/promises'

async function getCachedData() {
'use cache'

cacheLife('seconds')

await setTimeout(1000)

return new Date().toISOString()
}

export async function GET() {
const cached = await getCachedData()
const dynamic = new Date().toISOString()

return Response.json({ cached, dynamic })
}
43 changes: 43 additions & 0 deletions test/e2e/app-dir/use-cache-swr/use-cache-swr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,49 @@ describe('use-cache-swr', () => {
expect(duration3).toBeLessThan(1000)
})

it('should serve stale data without blocking on the background regeneration (route handler)', async () => {
// Fetch 1: cold cache. The cached function blocks for ~1s.
const res1 = await next.fetch('/delayed-route')
const { cached: cached1, dynamic: dynamic1 } = await res1.json()
expect(cached1).toBeDateString()
expect(dynamic1).toBeDateString()

// Wait past the 1s revalidate window (cacheLife('seconds')).
await new Promise((resolve) => setTimeout(resolve, 1200))

outputIndex = next.cliOutput.length

// Fetch 2: stale hit. Should return the stale entry immediately and kick
// off the regeneration in the background, rather than blocking on the 1s
// delay in the cached function.
const start2 = Date.now()
const res2 = await next.fetch('/delayed-route')
const { cached: cached2, dynamic: dynamic2 } = await res2.json()
const duration2 = Date.now() - start2

expect(cached2).toBe(cached1)
expect(dynamic2).not.toBe(dynamic1)
expect(duration2).toBeLessThan(1000)

// Wait for the background regen to finish writing the fresh entry.
await retry(() => {
expect(next.cliOutput.slice(outputIndex)).toMatch(
/PersistentCacheHandler::set/
)
})

// Fetch 3: should serve the pre-warmed fresh entry from the background
// regen, not a new stale value.
const start3 = Date.now()
const res3 = await next.fetch('/delayed-route')
const { cached: cached3, dynamic: dynamic3 } = await res3.json()
const duration3 = Date.now() - start3

expect(cached3).not.toBe(cached1)
expect(dynamic3).not.toBe(dynamic2)
expect(duration3).toBeLessThan(1000)
})

it('should pass implicit tags to cache handler get() for nested caches during SWR', async () => {
const browser = await next.browser('/')
await browser.elementById('outer-data').text()
Expand Down
Loading