@trieb.work/nextjs-turbo-redis-cache 1.16.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +11 -2
- package/CHANGELOG.md +14 -0
- package/README.md +4 -1
- package/dist/index.js +20 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/RedisStringsHandler.ts +26 -15
- package/test/README.md +3 -3
- package/test/nextjs-test-projects/next-app-15-4-11/pnpm-lock.yaml +1 -1
- package/test/nextjs-test-projects/next-app-16-0-11/pnpm-lock.yaml +1 -1
- package/test/nextjs-test-projects/next-app-16-0-11-cache-components/pnpm-lock.yaml +1 -1
- package/test/nextjs-test-projects/next-app-16-2-6/pnpm-lock.yaml +1 -1
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/pnpm-lock.yaml +1 -1
- package/test/nextjs-test-projects/next-app-16-3-0/README.md +36 -0
- package/test/nextjs-test-projects/next-app-16-3-0/eslint.config.mjs +18 -0
- package/test/nextjs-test-projects/next-app-16-3-0/next.config.ts +7 -0
- package/test/nextjs-test-projects/next-app-16-3-0/package.json +28 -0
- package/test/nextjs-test-projects/next-app-16-3-0/pnpm-lock.yaml +4284 -0
- package/test/nextjs-test-projects/next-app-16-3-0/postcss.config.mjs +7 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/cached-static-fetch/route.ts +18 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +27 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/revalidatePath/route.ts +15 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/revalidateTag/route.ts +20 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/revalidated-fetch/route.ts +17 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/uncached-fetch/route.ts +15 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/favicon.ico +0 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/globals.css +26 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/layout.tsx +59 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/page.tsx +755 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +19 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +34 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +25 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/no-fetch/default-page/page.tsx +55 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +19 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +35 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +25 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +19 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +32 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +25 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/revalidation-interface.tsx +267 -0
- package/test/nextjs-test-projects/next-app-16-3-0/src/app/update-tag-test/page.tsx +25 -0
- package/test/nextjs-test-projects/next-app-16-3-0/tsconfig.json +34 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/README.md +36 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/cache-handler.js +3 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/eslint.config.mjs +18 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/next.config.ts +13 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/package.json +28 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/pnpm-lock.yaml +4284 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/postcss.config.mjs +7 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/file.svg +1 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/globe.svg +1 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/next.svg +1 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/vercel.svg +1 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/window.svg +1 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/cached-static-fetch/route.ts +19 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/cached-with-cachelife/route.ts +24 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/cached-with-tag/route.ts +21 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/revalidate-tag/route.ts +19 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/revalidated-fetch/route.ts +19 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/cachelife-short/page.tsx +110 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/page.tsx +90 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/runtime-data-suspense/page.tsx +127 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/stale-while-revalidate/page.tsx +130 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/tag-invalidation/page.tsx +127 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/use-cache-nondeterministic/page.tsx +110 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/favicon.ico +0 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/globals.css +26 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/layout.tsx +57 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/page.tsx +755 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/revalidation-interface.tsx +267 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/update-tag-test/page.tsx +22 -0
- package/test/nextjs-test-projects/next-app-16-3-0-cache-components/tsconfig.json +34 -0
- package/test/nextjs-test-projects/next-pages-16-2-6/pnpm-lock.yaml +4 -4
- package/test/nextjs-test-projects/next-pages-16-3-0/README.md +16 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/eslint.config.mjs +18 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/next.config.ts +7 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/package.json +26 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/pnpm-lock.yaml +3939 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/api/revalidate.ts +24 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/index.tsx +11 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/isr/[slug].tsx +49 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/static-forever.tsx +20 -0
- package/test/nextjs-test-projects/next-pages-16-3-0/tsconfig.json +34 -0
- package/test/vitest/integration/nextjs-cache-handler.integration.test.ts +51 -32
- package/test/vitest/unit/index.test.ts +28 -0
|
@@ -444,21 +444,32 @@ export default class RedisStringsHandler {
|
|
|
444
444
|
'assertClientIsReady called more than 10 times without being ready.',
|
|
445
445
|
);
|
|
446
446
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
447
|
+
let readyTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
448
|
+
try {
|
|
449
|
+
await Promise.race([
|
|
450
|
+
Promise.all([
|
|
451
|
+
this.sharedTagsMap.waitUntilReady(),
|
|
452
|
+
this.revalidatedTagsMap.waitUntilReady(),
|
|
453
|
+
]),
|
|
454
|
+
new Promise((_, reject) => {
|
|
455
|
+
readyTimeout = setTimeout(() => {
|
|
456
|
+
reject(
|
|
457
|
+
new Error(
|
|
458
|
+
'assertClientIsReady: Timeout waiting for Redis maps to be ready',
|
|
459
|
+
),
|
|
460
|
+
);
|
|
461
|
+
}, 30_000);
|
|
462
|
+
}),
|
|
463
|
+
]);
|
|
464
|
+
} finally {
|
|
465
|
+
// Always clear the timeout: once the race is won (the common case after
|
|
466
|
+
// the initial sync), the timer would otherwise stay pending for the full
|
|
467
|
+
// 30s. Timers capture the ambient async context (AsyncLocalStorage),
|
|
468
|
+
// so in a Next.js server every leaked timer pins the request's store —
|
|
469
|
+
// and with it the whole response object graph — for at least 30s on
|
|
470
|
+
// every single cache operation.
|
|
471
|
+
clearTimeout(readyTimeout);
|
|
472
|
+
}
|
|
462
473
|
this.clientReadyCalls = 0;
|
|
463
474
|
if (!this.client.isReady) {
|
|
464
475
|
throw new Error(
|
package/test/README.md
CHANGED
|
@@ -55,7 +55,7 @@ These tests spawn a real Next.js server as a child process, make `fetch()` reque
|
|
|
55
55
|
|
|
56
56
|
### Standard Integration (`nextjs-cache-handler.integration.test.ts`)
|
|
57
57
|
|
|
58
|
-
Full cache lifecycle: static pages, fetch caching, revalidation, tag invalidation, TTL behavior. In CI this runs against
|
|
58
|
+
Full cache lifecycle: static pages, fetch caching, revalidation, tag invalidation, TTL behavior. In CI this runs against Next.js 15.4, 16.0, 16.2, and 16.3. Nested fetch entries are resolved from their explicit cache tag in Redis's shared-tags map rather than Next.js's internal fetch-key hash, which changed in Next.js 16.3.
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
61
|
pnpm test:integration
|
|
@@ -63,7 +63,7 @@ pnpm test:integration
|
|
|
63
63
|
|
|
64
64
|
### Pages Router (`pages-router.integration.test.ts`)
|
|
65
65
|
|
|
66
|
-
Pages Router cache lifecycle against the `next-pages-16-2-6`
|
|
66
|
+
Pages Router cache lifecycle against the `next-pages-16-2-6` and `next-pages-16-3-0` apps: `PAGES` entry format, TTL derivation from `getStaticProps` `revalidate`, `fallback: 'blocking'` first hits, `notFound: true` (null cache entries), `redirect:` results, and `revalidate: false` TTL fallback.
|
|
67
67
|
|
|
68
68
|
Starts **two** `next start` instances of the same build sharing one Redis and proves that on-demand revalidation (`res.revalidate(path)`) triggered on instance A is served fresh by instance B (HTML and `/_next/data` pageData JSON) — the multi-instance ISR scenario behind a load balancer.
|
|
69
69
|
|
|
@@ -81,7 +81,7 @@ pnpm test:integration:build-id-prefix
|
|
|
81
81
|
|
|
82
82
|
### Cache Components (`cache-components/`)
|
|
83
83
|
|
|
84
|
-
Integration tests specific to Next.js 16 Cache Components (`use cache`).
|
|
84
|
+
Integration tests specific to Next.js 16 Cache Components (`use cache`). CI runs them against the 16.0, 16.2, and 16.3 Cache Components test apps.
|
|
85
85
|
|
|
86
86
|
| File | What it tests |
|
|
87
87
|
| -------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
@@ -492,7 +492,7 @@ packages:
|
|
|
492
492
|
'@trieb.work/nextjs-turbo-redis-cache@file:../../..':
|
|
493
493
|
resolution: {directory: ../../.., type: directory}
|
|
494
494
|
peerDependencies:
|
|
495
|
-
next: '>=15.0.3 <
|
|
495
|
+
next: '>=15.0.3 <17.0.0'
|
|
496
496
|
redis: 4.7.0
|
|
497
497
|
|
|
498
498
|
'@tybys/wasm-util@0.9.0':
|
|
@@ -561,7 +561,7 @@ packages:
|
|
|
561
561
|
'@trieb.work/nextjs-turbo-redis-cache@file:../../..':
|
|
562
562
|
resolution: {directory: ../../.., type: directory}
|
|
563
563
|
peerDependencies:
|
|
564
|
-
next: '>=15.0.3 <
|
|
564
|
+
next: '>=15.0.3 <17.0.0'
|
|
565
565
|
redis: 4.7.0
|
|
566
566
|
|
|
567
567
|
'@tybys/wasm-util@0.10.1':
|
|
@@ -568,7 +568,7 @@ packages:
|
|
|
568
568
|
'@trieb.work/nextjs-turbo-redis-cache@file:../../..':
|
|
569
569
|
resolution: {directory: ../../.., type: directory}
|
|
570
570
|
peerDependencies:
|
|
571
|
-
next: '>=15.0.3 <
|
|
571
|
+
next: '>=15.0.3 <17.0.0'
|
|
572
572
|
redis: 4.7.0
|
|
573
573
|
|
|
574
574
|
'@tybys/wasm-util@0.10.2':
|
|
@@ -561,7 +561,7 @@ packages:
|
|
|
561
561
|
'@trieb.work/nextjs-turbo-redis-cache@file:../../..':
|
|
562
562
|
resolution: {directory: ../../.., type: directory}
|
|
563
563
|
peerDependencies:
|
|
564
|
-
next: '>=15.0.3 <
|
|
564
|
+
next: '>=15.0.3 <17.0.0'
|
|
565
565
|
redis: 4.7.0
|
|
566
566
|
|
|
567
567
|
'@tybys/wasm-util@0.10.1':
|
|
@@ -561,7 +561,7 @@ packages:
|
|
|
561
561
|
'@trieb.work/nextjs-turbo-redis-cache@file:../../..':
|
|
562
562
|
resolution: {directory: ../../.., type: directory}
|
|
563
563
|
peerDependencies:
|
|
564
|
-
next: '>=15.0.3 <
|
|
564
|
+
next: '>=15.0.3 <17.0.0'
|
|
565
565
|
redis: 4.7.0
|
|
566
566
|
|
|
567
567
|
'@tybys/wasm-util@0.10.1':
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
First, run the development server:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run dev
|
|
9
|
+
# or
|
|
10
|
+
yarn dev
|
|
11
|
+
# or
|
|
12
|
+
pnpm dev
|
|
13
|
+
# or
|
|
14
|
+
bun dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
18
|
+
|
|
19
|
+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
|
20
|
+
|
|
21
|
+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
|
22
|
+
|
|
23
|
+
## Learn More
|
|
24
|
+
|
|
25
|
+
To learn more about Next.js, take a look at the following resources:
|
|
26
|
+
|
|
27
|
+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
28
|
+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
29
|
+
|
|
30
|
+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
|
31
|
+
|
|
32
|
+
## Deploy on Vercel
|
|
33
|
+
|
|
34
|
+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
35
|
+
|
|
36
|
+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
3
|
+
import nextTs from "eslint-config-next/typescript";
|
|
4
|
+
|
|
5
|
+
const eslintConfig = defineConfig([
|
|
6
|
+
...nextVitals,
|
|
7
|
+
...nextTs,
|
|
8
|
+
// Override default ignores of eslint-config-next.
|
|
9
|
+
globalIgnores([
|
|
10
|
+
// Default ignores of eslint-config-next:
|
|
11
|
+
".next/**",
|
|
12
|
+
"out/**",
|
|
13
|
+
"build/**",
|
|
14
|
+
"next-env.d.ts",
|
|
15
|
+
]),
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export default eslintConfig;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "next-app-16-3-0",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start",
|
|
9
|
+
"lint": "eslint"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"next": "16.3.0",
|
|
13
|
+
"react": "19.2.0",
|
|
14
|
+
"react-dom": "19.2.0",
|
|
15
|
+
"redis": "4.7.0",
|
|
16
|
+
"@trieb.work/nextjs-turbo-redis-cache": "file:../../../"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@tailwindcss/postcss": "^4",
|
|
20
|
+
"@types/node": "^20",
|
|
21
|
+
"@types/react": "^19",
|
|
22
|
+
"@types/react-dom": "^19",
|
|
23
|
+
"eslint": "^9",
|
|
24
|
+
"eslint-config-next": "16.3.0",
|
|
25
|
+
"tailwindcss": "^4",
|
|
26
|
+
"typescript": "^5"
|
|
27
|
+
}
|
|
28
|
+
}
|