@trieb.work/nextjs-turbo-redis-cache 1.14.1 → 1.15.1
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/.cursor/skills/testing/SKILL.md +121 -0
- package/.github/workflows/ci.yml +155 -70
- package/.github/workflows/pages.yml +38 -0
- package/ARCHITECTURE.md +431 -0
- package/CHANGELOG.md +19 -0
- package/README.md +220 -48
- package/dist/index.d.mts +77 -2
- package/dist/index.d.ts +77 -2
- package/dist/index.js +109 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -23
- package/dist/index.mjs.map +1 -1
- package/docs/index.html +139 -0
- package/docs/robots.txt +4 -0
- package/docs/sitemap.xml +8 -0
- package/docs/styles.css +141 -0
- package/eslint.config.mjs +1 -1
- package/package.json +16 -18
- package/playwright.config.ts +5 -3
- package/src/CacheComponentsHandler.ts +57 -2
- package/src/RedisStringsHandler.ts +48 -11
- package/src/SyncedMap.ts +62 -13
- package/src/index.ts +4 -0
- package/src/serializer.ts +59 -0
- package/test/README.md +179 -0
- package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/package.json +6 -6
- package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-15-4-11}/pnpm-lock.yaml +89 -105
- package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11}/package.json +3 -3
- package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11}/pnpm-lock.yaml +53 -53
- package/test/nextjs-test-projects/next-app-16-0-11-cache-components/package.json +28 -0
- package/test/nextjs-test-projects/next-app-16-0-11-cache-components/pnpm-lock.yaml +4206 -0
- package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/cached-with-cachelife/route.ts +24 -0
- package/test/nextjs-test-projects/next-app-16-2-6/eslint.config.mjs +18 -0
- package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6}/package.json +3 -3
- package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6}/pnpm-lock.yaml +54 -60
- package/test/nextjs-test-projects/next-app-16-2-6/postcss.config.mjs +7 -0
- package/test/nextjs-test-projects/next-app-16-2-6/src/app/favicon.ico +0 -0
- package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-2-6}/tsconfig.json +9 -2
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/cache-handler.js +3 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/next.config.ts +13 -0
- package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-2-6-cache-components}/package.json +3 -3
- package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-2-6-cache-components}/pnpm-lock.yaml +54 -60
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/cached-static-fetch/route.ts +19 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/cached-with-cachelife/route.ts +24 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/cached-with-tag/route.ts +21 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/revalidate-tag/route.ts +19 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/revalidated-fetch/route.ts +19 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/cachelife-short/page.tsx +110 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/page.tsx +90 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/runtime-data-suspense/page.tsx +127 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/stale-while-revalidate/page.tsx +130 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/tag-invalidation/page.tsx +127 -0
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/use-cache-nondeterministic/page.tsx +110 -0
- package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/src/app/layout.tsx +0 -2
- package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/update-tag-test/page.tsx +22 -0
- package/{tests → test/playwright}/update-tag.spec.ts +1 -1
- package/test/{integration → vitest/integration}/build-id-prefix.integration.test.ts +2 -2
- package/test/{cache-components/cache-components.integration.spec.ts → vitest/integration/cache-components/cache-components.integration.test.ts} +46 -3
- package/test/{cache-components/redis-kill-reconnect.spec.ts → vitest/integration/cache-components/redis-kill-reconnect.test.ts} +28 -7
- package/test/vitest/integration/cache-components/redis-quit-vs-disconnect.test.ts +59 -0
- package/test/vitest/integration/cache-components/redis-subscriber-outage.test.ts +100 -0
- package/test/{cache-components → vitest/integration/cache-components}/scripts/redis-kill-reconnect.ts +31 -8
- package/test/vitest/integration/cache-components/scripts/redis-quit-vs-disconnect.ts +113 -0
- package/test/vitest/integration/cache-components/scripts/redis-subscriber-outage.ts +379 -0
- package/test/vitest/integration/cache-components/scripts/redis-test-helpers.ts +155 -0
- package/test/{integration → vitest/integration}/nextjs-cache-handler.integration.test.ts +17 -10
- package/test/vitest/unit/SyncedMap-reconnect-repro.test.ts +154 -0
- package/{src → test/vitest/unit}/index.test.ts +3 -3
- package/test/{cache-components/reconnect-socket-already-opened.spec.ts → vitest/unit/reconnect-socket-already-opened.test.ts} +1 -1
- package/test/vitest/unit/serializer.test.ts +182 -0
- package/{src → test/vitest/unit}/utils/prefix.test.ts +1 -1
- package/vite.config.ts +4 -3
- package/vitest.cache-components.config.ts +1 -1
- package/test/browser/update-tag.browser.test.ts +0 -41
- package/test/integration/next-app-15-0-3/next.config.js +0 -6
- package/test/integration/next-app-15-0-3/package-lock.json +0 -5833
- package/test/integration/next-app-15-0-3/pnpm-lock.yaml +0 -3710
- package/test/integration/next-app-15-3-2/next.config.js +0 -6
- package/test/integration/next-app-15-3-2/package.json +0 -33
- package/test/integration/next-app-15-3-2/pnpm-lock.yaml +0 -3720
- package/test/integration/next-app-15-3-2/postcss.config.mjs +0 -5
- package/test/integration/next-app-15-3-2/src/app/api/revalidateTag/route.ts +0 -15
- package/test/integration/next-app-15-4-7/eslint.config.mjs +0 -16
- package/test/integration/next-app-15-4-7/package-lock.json +0 -5969
- package/test/integration/next-app-15-4-7/package.json +0 -33
- package/test/integration/next-app-15-4-7/postcss.config.mjs +0 -5
- package/test/integration/next-app-15-4-7/src/app/api/revalidateTag/route.ts +0 -15
- package/test/integration/next-app-15-4-7/tsconfig.json +0 -27
- package/test/integration/next-app-16-0-3/src/app/api/cached-static-fetch/route.ts +0 -18
- package/test/integration/next-app-16-0-3/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -27
- package/test/integration/next-app-16-0-3/src/app/api/revalidatePath/route.ts +0 -15
- package/test/integration/next-app-16-0-3/src/app/api/revalidated-fetch/route.ts +0 -17
- package/test/integration/next-app-16-0-3/src/app/api/uncached-fetch/route.ts +0 -15
- package/test/integration/next-app-16-0-3/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -19
- package/test/integration/next-app-16-0-3/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -34
- package/test/integration/next-app-16-0-3/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
- package/test/integration/next-app-16-0-3/src/app/pages/no-fetch/default-page/page.tsx +0 -55
- package/test/integration/next-app-16-0-3/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -19
- package/test/integration/next-app-16-0-3/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -35
- package/test/integration/next-app-16-0-3/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
- package/test/integration/next-app-16-0-3/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -19
- package/test/integration/next-app-16-0-3/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -32
- package/test/integration/next-app-16-0-3/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
- package/test/integration/next-app-16-2-3/src/app/api/cached-static-fetch/route.ts +0 -18
- package/test/integration/next-app-16-2-3/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -27
- package/test/integration/next-app-16-2-3/src/app/api/revalidatePath/route.ts +0 -15
- package/test/integration/next-app-16-2-3/src/app/api/revalidated-fetch/route.ts +0 -17
- package/test/integration/next-app-16-2-3/src/app/api/uncached-fetch/route.ts +0 -15
- package/test/integration/next-app-16-2-3/src/app/globals.css +0 -26
- package/test/integration/next-app-16-2-3/src/app/layout.tsx +0 -59
- package/test/integration/next-app-16-2-3/src/app/page.tsx +0 -755
- package/test/integration/next-app-16-2-3/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -19
- package/test/integration/next-app-16-2-3/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -34
- package/test/integration/next-app-16-2-3/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
- package/test/integration/next-app-16-2-3/src/app/pages/no-fetch/default-page/page.tsx +0 -55
- package/test/integration/next-app-16-2-3/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -19
- package/test/integration/next-app-16-2-3/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -35
- package/test/integration/next-app-16-2-3/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
- package/test/integration/next-app-16-2-3/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -19
- package/test/integration/next-app-16-2-3/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -32
- package/test/integration/next-app-16-2-3/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
- package/test/integration/next-app-16-2-3/src/app/revalidation-interface.tsx +0 -267
- package/test/integration/next-app-16-2-3-cache-components/public/file.svg +0 -1
- package/test/integration/next-app-16-2-3-cache-components/public/globe.svg +0 -1
- package/test/integration/next-app-16-2-3-cache-components/public/next.svg +0 -1
- package/test/integration/next-app-16-2-3-cache-components/public/vercel.svg +0 -1
- package/test/integration/next-app-16-2-3-cache-components/public/window.svg +0 -1
- package/test/integration/next-app-customized/README.md +0 -36
- package/test/integration/next-app-customized/eslint.config.mjs +0 -16
- package/vitest.browser.config.ts +0 -10
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/README.md +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/eslint.config.mjs +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-15-4-11}/next.config.js +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-15-4-11}/package-lock.json +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/postcss.config.mjs +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/public/file.svg +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/public/globe.svg +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/public/next.svg +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/public/vercel.svg +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/public/window.svg +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/api/cached-static-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/api/revalidatePath/route.ts +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/api/revalidateTag/route.ts +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/api/revalidated-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/api/uncached-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/globals.css +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/layout.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/no-fetch/default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/src/app/revalidation-interface.tsx +0 -0
- /package/test/{integration/next-app-15-0-3 → nextjs-test-projects/next-app-15-4-11}/tsconfig.json +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-0-11}/README.md +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11}/eslint.config.mjs +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11}/next.config.ts +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11}/postcss.config.mjs +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/api/cached-static-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/api/revalidatePath/route.ts +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11}/src/app/api/revalidateTag/route.ts +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/api/revalidated-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/api/uncached-fetch/route.ts +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11}/src/app/favicon.ico +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-0-11}/src/app/globals.css +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/layout.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-0-11}/src/app/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/no-fetch/default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11}/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-0-11}/src/app/revalidation-interface.tsx +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11}/src/app/update-tag-test/page.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11}/tsconfig.json +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/README.md +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/cache-handler.js +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11-cache-components}/eslint.config.mjs +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/next.config.ts +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11-cache-components}/postcss.config.mjs +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/public/file.svg +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/public/globe.svg +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/public/next.svg +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/public/vercel.svg +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/public/window.svg +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/api/cached-static-fetch/route.ts +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/api/cached-with-tag/route.ts +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/api/revalidate-tag/route.ts +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/api/revalidated-fetch/route.ts +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/cache-lab/cachelife-short/page.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/cache-lab/page.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/cache-lab/runtime-data-suspense/page.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/cache-lab/stale-while-revalidate/page.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/cache-lab/tag-invalidation/page.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/cache-lab/use-cache-nondeterministic/page.tsx +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/favicon.ico +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/globals.css +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/layout.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/page.tsx +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/revalidation-interface.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-0-11-cache-components}/src/app/update-tag-test/page.tsx +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-0-11-cache-components}/tsconfig.json +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-2-6}/README.md +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6}/next.config.ts +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/api/cached-static-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/api/revalidatePath/route.ts +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6}/src/app/api/revalidateTag/route.ts +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/api/revalidated-fetch/route.ts +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/api/uncached-fetch/route.ts +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-2-6}/src/app/globals.css +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/layout.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-2-6}/src/app/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/no-fetch/default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6}/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -0
- /package/test/{integration/next-app-16-2-3-cache-components → nextjs-test-projects/next-app-16-2-6}/src/app/revalidation-interface.tsx +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6}/src/app/update-tag-test/page.tsx +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/README.md +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/eslint.config.mjs +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/postcss.config.mjs +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6-cache-components}/public/file.svg +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6-cache-components}/public/globe.svg +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6-cache-components}/public/next.svg +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6-cache-components}/public/vercel.svg +0 -0
- /package/test/{integration/next-app-15-4-7 → nextjs-test-projects/next-app-16-2-6-cache-components}/public/window.svg +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/src/app/favicon.ico +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/src/app/globals.css +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/src/app/page.tsx +0 -0
- /package/test/{integration/next-app-16-0-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/src/app/revalidation-interface.tsx +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-16-2-6-cache-components}/tsconfig.json +0 -0
- /package/test/{integration/next-app-16-2-3 → nextjs-test-projects/next-app-customized}/README.md +0 -0
- /package/test/{integration → nextjs-test-projects}/next-app-customized/customized-cache-handler.js +0 -0
- /package/test/{integration/next-app-15-3-2 → nextjs-test-projects/next-app-customized}/eslint.config.mjs +0 -0
- /package/test/{integration → nextjs-test-projects}/next-app-customized/next.config.js +0 -0
- /package/{tests → test/playwright}/cache-lab.spec.ts +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
hasContainerRuntime,
|
|
5
|
+
runNode,
|
|
6
|
+
parseResults,
|
|
7
|
+
type TestResult,
|
|
8
|
+
} from './scripts/redis-test-helpers';
|
|
9
|
+
|
|
10
|
+
const describeOrSkip = hasContainerRuntime() ? describe : describe.skip;
|
|
11
|
+
|
|
12
|
+
describeOrSkip('subscriber teardown: quit() vs disconnect()', () => {
|
|
13
|
+
let results: Map<string, TestResult>;
|
|
14
|
+
let exitCode: number;
|
|
15
|
+
let stderr: string;
|
|
16
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
const script = path.join(
|
|
19
|
+
__dirname,
|
|
20
|
+
'scripts',
|
|
21
|
+
'redis-quit-vs-disconnect.ts',
|
|
22
|
+
);
|
|
23
|
+
const res = await runNode(script, 60_000);
|
|
24
|
+
exitCode = res.code;
|
|
25
|
+
stderr = res.stderr;
|
|
26
|
+
results = parseResults(res.stdout);
|
|
27
|
+
}, 60_000);
|
|
28
|
+
|
|
29
|
+
it('script exits successfully', () => {
|
|
30
|
+
if (exitCode !== 0) {
|
|
31
|
+
process.stderr.write(stderr);
|
|
32
|
+
}
|
|
33
|
+
expect(exitCode).toBe(0);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('subscriber clients are ready before outage', () => {
|
|
37
|
+
const r = results.get('subscribers-ready');
|
|
38
|
+
expect(r).toBeDefined();
|
|
39
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('quit() does not immediately close a subscriber during outage', () => {
|
|
43
|
+
const r = results.get('quit-does-not-immediately-close');
|
|
44
|
+
expect(r).toBeDefined();
|
|
45
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('disconnect() closes the subscriber immediately during outage', () => {
|
|
49
|
+
const r = results.get('disconnect-closes-immediately');
|
|
50
|
+
expect(r).toBeDefined();
|
|
51
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('disconnected subscriber stays dead after Redis restarts', () => {
|
|
55
|
+
const r = results.get('disconnected-client-stays-dead');
|
|
56
|
+
expect(r).toBeDefined();
|
|
57
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll } from 'vitest';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
hasContainerRuntime,
|
|
5
|
+
runNode,
|
|
6
|
+
parseResults,
|
|
7
|
+
type TestResult,
|
|
8
|
+
} from './scripts/redis-test-helpers';
|
|
9
|
+
|
|
10
|
+
const describeOrSkip = hasContainerRuntime() ? describe : describe.skip;
|
|
11
|
+
|
|
12
|
+
describeOrSkip('issue #86: subscriber outage recovery', () => {
|
|
13
|
+
let results: Map<string, TestResult>;
|
|
14
|
+
|
|
15
|
+
beforeAll(async () => {
|
|
16
|
+
const script = path.join(
|
|
17
|
+
__dirname,
|
|
18
|
+
'scripts',
|
|
19
|
+
'redis-subscriber-outage.ts',
|
|
20
|
+
);
|
|
21
|
+
const res = await runNode(script, 300_000);
|
|
22
|
+
// Script always exits 0 (it records pass/fail per sub-test)
|
|
23
|
+
if (res.code !== 0) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Script exited with code ${res.code}\nstdout:\n${res.stdout}\nstderr:\n${res.stderr}`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
results = parseResults(res.stdout);
|
|
29
|
+
}, 300_000);
|
|
30
|
+
|
|
31
|
+
// --- Tests that should PASS (verify correct behavior before outage) ---
|
|
32
|
+
|
|
33
|
+
it('PubSub sync works before outage', () => {
|
|
34
|
+
const r = results.get('pubsub-initial-strings');
|
|
35
|
+
expect(r).toBeDefined();
|
|
36
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('subscriber clients have error listeners before outage', () => {
|
|
40
|
+
const r = results.get('error-listener-initial');
|
|
41
|
+
expect(r).toBeDefined();
|
|
42
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// --- Tests that verify symptoms during outage ---
|
|
46
|
+
|
|
47
|
+
it('get() returns null during outage', () => {
|
|
48
|
+
const r = results.get('get-during-outage');
|
|
49
|
+
expect(r).toBeDefined();
|
|
50
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('heap does not grow excessively during 50 get() calls in outage', () => {
|
|
54
|
+
const r = results.get('heap-growth-during-outage');
|
|
55
|
+
expect(r).toBeDefined();
|
|
56
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('main client reconnects after Redis restart', () => {
|
|
60
|
+
const r = results.get('main-client-reconnects');
|
|
61
|
+
expect(r).toBeDefined();
|
|
62
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('get() works after Redis restart (main client path)', () => {
|
|
66
|
+
const r = results.get('get-after-outage');
|
|
67
|
+
expect(r).toBeDefined();
|
|
68
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// --- Tests that reproduce the bug (EXPECTED TO FAIL with current code) ---
|
|
72
|
+
|
|
73
|
+
it('PubSub sync works after outage (issue #86 — subscriber never recovers)', () => {
|
|
74
|
+
const r = results.get('pubsub-after-outage-strings');
|
|
75
|
+
expect(r).toBeDefined();
|
|
76
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('subscriber error listener state after outage (informational)', () => {
|
|
80
|
+
const r = results.get('error-listener-after-outage');
|
|
81
|
+
expect(r).toBeDefined();
|
|
82
|
+
// Informational — always passes. Detail shows whether the listener
|
|
83
|
+
// survived and whether the subscriber client object was replaced.
|
|
84
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('duplicate() call count during outage (informational)', () => {
|
|
88
|
+
const r = results.get('duplicate-count-during-outage');
|
|
89
|
+
expect(r).toBeDefined();
|
|
90
|
+
// Informational — always passes. Detail has the actual count.
|
|
91
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('total duplicate() call count (informational)', () => {
|
|
95
|
+
const r = results.get('duplicate-count-total');
|
|
96
|
+
expect(r).toBeDefined();
|
|
97
|
+
// Informational — always passes. Detail has the actual count.
|
|
98
|
+
expect(r!.pass, r!.detail).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from 'child_process';
|
|
2
2
|
|
|
3
|
+
type ContainerRuntime = 'podman' | 'docker';
|
|
4
|
+
|
|
3
5
|
function sh(cmd: string, args: string[], opts: { timeoutMs?: number } = {}) {
|
|
4
6
|
const res = spawnSync(cmd, args, {
|
|
5
7
|
encoding: 'utf8',
|
|
@@ -13,6 +15,26 @@ function sh(cmd: string, args: string[], opts: { timeoutMs?: number } = {}) {
|
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
function canRun(cmd: string) {
|
|
19
|
+
const res = spawnSync(cmd, ['--version'], {
|
|
20
|
+
encoding: 'utf8',
|
|
21
|
+
timeout: 3_000,
|
|
22
|
+
});
|
|
23
|
+
return !res.error && (res.status ?? 1) === 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function detectContainerRuntime(): ContainerRuntime {
|
|
27
|
+
if (process.env.CONTAINER_RUNTIME === 'podman') return 'podman';
|
|
28
|
+
if (process.env.CONTAINER_RUNTIME === 'docker') return 'docker';
|
|
29
|
+
|
|
30
|
+
if (canRun('podman')) return 'podman';
|
|
31
|
+
if (canRun('docker')) return 'docker';
|
|
32
|
+
|
|
33
|
+
throw new Error(
|
|
34
|
+
'Neither podman nor docker is available. Install one of them or set CONTAINER_RUNTIME.',
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
async function sleep(ms: number) {
|
|
17
39
|
await new Promise((r) => setTimeout(r, ms));
|
|
18
40
|
}
|
|
@@ -28,6 +50,7 @@ async function waitUntil(fn: () => Promise<boolean>, timeoutMs = 20_000) {
|
|
|
28
50
|
}
|
|
29
51
|
|
|
30
52
|
async function main() {
|
|
53
|
+
const runtime = detectContainerRuntime();
|
|
31
54
|
const name = `redis-e2e-${Math.random().toString(36).slice(2, 8)}`;
|
|
32
55
|
|
|
33
56
|
// Pick a free localhost port
|
|
@@ -45,12 +68,12 @@ async function main() {
|
|
|
45
68
|
});
|
|
46
69
|
|
|
47
70
|
// cleanup
|
|
48
|
-
sh(
|
|
71
|
+
sh(runtime, ['rm', '-f', name]);
|
|
49
72
|
|
|
50
73
|
// Start redis with keyspace notifications enabled (required by SyncedMap)
|
|
51
74
|
{
|
|
52
75
|
const r = sh(
|
|
53
|
-
|
|
76
|
+
runtime,
|
|
54
77
|
[
|
|
55
78
|
'run',
|
|
56
79
|
'-d',
|
|
@@ -75,10 +98,10 @@ async function main() {
|
|
|
75
98
|
process.env.VERCEL_URL = `e2e-${name}-`;
|
|
76
99
|
|
|
77
100
|
const { getRedisCacheComponentsHandler } = await import(
|
|
78
|
-
'
|
|
101
|
+
'../../../../../src/CacheComponentsHandler'
|
|
79
102
|
);
|
|
80
103
|
const { default: RedisStringsHandler } = await import(
|
|
81
|
-
'
|
|
104
|
+
'../../../../../src/RedisStringsHandler'
|
|
82
105
|
);
|
|
83
106
|
|
|
84
107
|
// Cache Components handler
|
|
@@ -153,14 +176,14 @@ async function main() {
|
|
|
153
176
|
if (!got) throw new Error('expected cache hit (regular handler)');
|
|
154
177
|
|
|
155
178
|
// Kill redis
|
|
156
|
-
sh(
|
|
179
|
+
sh(runtime, ['stop', '-t', '0', name], { timeoutMs: 30_000 });
|
|
157
180
|
|
|
158
181
|
// Wait a bit, then start again
|
|
159
182
|
await sleep(500);
|
|
160
183
|
|
|
161
184
|
{
|
|
162
185
|
const r = sh(
|
|
163
|
-
|
|
186
|
+
runtime,
|
|
164
187
|
[
|
|
165
188
|
'run',
|
|
166
189
|
'-d',
|
|
@@ -176,7 +199,7 @@ async function main() {
|
|
|
176
199
|
],
|
|
177
200
|
{ timeoutMs: 60_000 },
|
|
178
201
|
);
|
|
179
|
-
if (r.code !== 0) throw new Error(
|
|
202
|
+
if (r.code !== 0) throw new Error(`${runtime} run2 failed: ${r.stderr}`);
|
|
180
203
|
}
|
|
181
204
|
|
|
182
205
|
// Should recover (both)
|
|
@@ -205,7 +228,7 @@ async function main() {
|
|
|
205
228
|
} catch {}
|
|
206
229
|
|
|
207
230
|
// cleanup best effort
|
|
208
|
-
sh(
|
|
231
|
+
sh(runtime, ['rm', '-f', name]);
|
|
209
232
|
|
|
210
233
|
// If we reach here without crashing due to Socket already opened, we're good.
|
|
211
234
|
// (Vitest will check stdout for this line.)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Demonstrates the difference between quit() and disconnect() on a
|
|
3
|
+
* node-redis subscriber client while Redis is down.
|
|
4
|
+
*
|
|
5
|
+
* Scenario:
|
|
6
|
+
* 1. Start Redis.
|
|
7
|
+
* 2. Connect two subscriber clients and subscribe them.
|
|
8
|
+
* 3. Kill Redis and wait for the reconnect loop to start.
|
|
9
|
+
* 4. Subscriber A: call quit(). It should NOT resolve quickly while Redis is down.
|
|
10
|
+
* 5. Subscriber B: call disconnect(). It must close the socket immediately.
|
|
11
|
+
* 6. Restart Redis and verify that the disconnected subscriber stays dead.
|
|
12
|
+
*
|
|
13
|
+
* This shows why disconnect() is the correct teardown method during an outage.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { createClient } from 'redis';
|
|
17
|
+
import {
|
|
18
|
+
detectContainerRuntime,
|
|
19
|
+
getFreePort,
|
|
20
|
+
record,
|
|
21
|
+
sh,
|
|
22
|
+
sleep,
|
|
23
|
+
startRedis,
|
|
24
|
+
} from './redis-test-helpers';
|
|
25
|
+
|
|
26
|
+
async function createSubscriber(url: string) {
|
|
27
|
+
const client = createClient({
|
|
28
|
+
url,
|
|
29
|
+
socket: {
|
|
30
|
+
connectTimeout: 2_000,
|
|
31
|
+
reconnectStrategy: (retries: number) => Math.min(50 + retries * 50, 500),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
client.on('error', () => {});
|
|
35
|
+
await client.connect();
|
|
36
|
+
await client.subscribe('test-channel', () => {});
|
|
37
|
+
return client;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function main() {
|
|
41
|
+
const runtime = detectContainerRuntime();
|
|
42
|
+
const name = `redis-quit-disc-${Math.random().toString(36).slice(2, 8)}`;
|
|
43
|
+
const port = await getFreePort();
|
|
44
|
+
|
|
45
|
+
sh(runtime, ['rm', '-f', name]);
|
|
46
|
+
startRedis(runtime, name, port);
|
|
47
|
+
|
|
48
|
+
const url = `redis://127.0.0.1:${port}`;
|
|
49
|
+
|
|
50
|
+
const quitSubscriber = await createSubscriber(url);
|
|
51
|
+
const disconnectSubscriber = await createSubscriber(url);
|
|
52
|
+
|
|
53
|
+
record(
|
|
54
|
+
'subscribers-ready',
|
|
55
|
+
quitSubscriber.isReady && disconnectSubscriber.isReady,
|
|
56
|
+
`quitSub isReady=${quitSubscriber.isReady}, disconnectSub isReady=${disconnectSubscriber.isReady}`,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// Kill Redis and let both clients enter their reconnect loops
|
|
60
|
+
sh(runtime, ['stop', '-t', '0', name], { timeoutMs: 30_000 });
|
|
61
|
+
await sleep(1_500);
|
|
62
|
+
|
|
63
|
+
// Test quit(): it should not resolve while Redis is unreachable.
|
|
64
|
+
const quitResult = await Promise.race([
|
|
65
|
+
quitSubscriber
|
|
66
|
+
.quit()
|
|
67
|
+
.then(() => 'resolved')
|
|
68
|
+
.catch((e) => `error:${e.message ?? e}`),
|
|
69
|
+
sleep(3_000).then(() => 'timeout'),
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
record(
|
|
73
|
+
'quit-does-not-immediately-close',
|
|
74
|
+
quitResult !== 'resolved',
|
|
75
|
+
`quit() result during outage: ${quitResult}`,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Test disconnect(): it must close the client immediately, even during outage.
|
|
79
|
+
const disconnectStart = Date.now();
|
|
80
|
+
try {
|
|
81
|
+
await disconnectSubscriber.disconnect();
|
|
82
|
+
} catch (e: any) {
|
|
83
|
+
// If the client is already closed, that's still a successful teardown.
|
|
84
|
+
}
|
|
85
|
+
const disconnectDuration = Date.now() - disconnectStart;
|
|
86
|
+
|
|
87
|
+
record(
|
|
88
|
+
'disconnect-closes-immediately',
|
|
89
|
+
!disconnectSubscriber.isOpen && !disconnectSubscriber.isReady,
|
|
90
|
+
`disconnect() took ${disconnectDuration}ms, isOpen=${disconnectSubscriber.isOpen}, isReady=${disconnectSubscriber.isReady}`,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Restart Redis and make sure the disconnected client does not come back.
|
|
94
|
+
startRedis(runtime, name, port);
|
|
95
|
+
await sleep(1_500);
|
|
96
|
+
|
|
97
|
+
record(
|
|
98
|
+
'disconnected-client-stays-dead',
|
|
99
|
+
!disconnectSubscriber.isOpen && !disconnectSubscriber.isReady,
|
|
100
|
+
`after restart: isOpen=${disconnectSubscriber.isOpen}, isReady=${disconnectSubscriber.isReady}`,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// Also clean up the quit subscriber so we don't leak the process.
|
|
104
|
+
try {
|
|
105
|
+
await quitSubscriber.disconnect();
|
|
106
|
+
} catch {}
|
|
107
|
+
sh(runtime, ['rm', '-f', name]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
main().catch((err) => {
|
|
111
|
+
process.stderr.write(String(err) + '\n');
|
|
112
|
+
process.exit(1);
|
|
113
|
+
});
|