@trieb.work/nextjs-turbo-redis-cache 1.18.0 → 1.18.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.
Files changed (318) hide show
  1. package/dist/index.js +27 -20
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +27 -20
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +6 -1
  6. package/.cursor/skills/testing/SKILL.md +0 -121
  7. package/.github/workflows/ci.yml +0 -309
  8. package/.github/workflows/pages.yml +0 -38
  9. package/.github/workflows/release.yml +0 -58
  10. package/.prettierrc.json +0 -6
  11. package/.vscode/settings.json +0 -10
  12. package/ARCHITECTURE.md +0 -470
  13. package/commitlint.config.cjs +0 -4
  14. package/docker/redis.conf +0 -1
  15. package/docs/index.html +0 -140
  16. package/docs/robots.txt +0 -4
  17. package/docs/sitemap.xml +0 -8
  18. package/docs/styles.css +0 -141
  19. package/eslint.config.mjs +0 -26
  20. package/hooks/commit-msg +0 -10
  21. package/hooks/pre-commit +0 -11
  22. package/playwright.config.ts +0 -18
  23. package/release.config.cjs +0 -12
  24. package/scripts/prepare.sh +0 -7
  25. package/scripts/setup-git.sh +0 -8
  26. package/scripts/setup-repo-name.sh +0 -17
  27. package/scripts/vitest-run-staged.cjs +0 -44
  28. package/src/CacheComponentsHandler.ts +0 -597
  29. package/src/CachedHandler.ts +0 -53
  30. package/src/DeduplicatedRequestHandler.ts +0 -110
  31. package/src/RedisStringsHandler.ts +0 -949
  32. package/src/SyncedMap.ts +0 -496
  33. package/src/ZodHandler.ts +0 -45
  34. package/src/index.ts +0 -23
  35. package/src/serializer.ts +0 -59
  36. package/src/utils/cacheTtl.ts +0 -71
  37. package/src/utils/compareAndUnlink.ts +0 -29
  38. package/src/utils/debug.ts +0 -30
  39. package/src/utils/json.ts +0 -49
  40. package/src/utils/prefix.ts +0 -44
  41. package/src/utils/redisConnection.ts +0 -17
  42. package/src/utils/tagRevalidation.ts +0 -162
  43. package/test/README.md +0 -194
  44. package/test/nextjs-test-projects/next-app-15-4-11/README.md +0 -36
  45. package/test/nextjs-test-projects/next-app-15-4-11/eslint.config.mjs +0 -16
  46. package/test/nextjs-test-projects/next-app-15-4-11/next.config.js +0 -9
  47. package/test/nextjs-test-projects/next-app-15-4-11/package-lock.json +0 -5969
  48. package/test/nextjs-test-projects/next-app-15-4-11/package.json +0 -29
  49. package/test/nextjs-test-projects/next-app-15-4-11/pnpm-lock.yaml +0 -3726
  50. package/test/nextjs-test-projects/next-app-15-4-11/postcss.config.mjs +0 -5
  51. package/test/nextjs-test-projects/next-app-15-4-11/public/file.svg +0 -1
  52. package/test/nextjs-test-projects/next-app-15-4-11/public/globe.svg +0 -1
  53. package/test/nextjs-test-projects/next-app-15-4-11/public/next.svg +0 -1
  54. package/test/nextjs-test-projects/next-app-15-4-11/public/vercel.svg +0 -1
  55. package/test/nextjs-test-projects/next-app-15-4-11/public/window.svg +0 -1
  56. package/test/nextjs-test-projects/next-app-15-4-11/src/app/api/cached-static-fetch/route.ts +0 -18
  57. package/test/nextjs-test-projects/next-app-15-4-11/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -27
  58. package/test/nextjs-test-projects/next-app-15-4-11/src/app/api/revalidatePath/route.ts +0 -15
  59. package/test/nextjs-test-projects/next-app-15-4-11/src/app/api/revalidateTag/route.ts +0 -15
  60. package/test/nextjs-test-projects/next-app-15-4-11/src/app/api/revalidated-fetch/route.ts +0 -17
  61. package/test/nextjs-test-projects/next-app-15-4-11/src/app/api/uncached-fetch/route.ts +0 -15
  62. package/test/nextjs-test-projects/next-app-15-4-11/src/app/globals.css +0 -26
  63. package/test/nextjs-test-projects/next-app-15-4-11/src/app/layout.tsx +0 -59
  64. package/test/nextjs-test-projects/next-app-15-4-11/src/app/page.tsx +0 -755
  65. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -19
  66. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -34
  67. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  68. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/no-fetch/default-page/page.tsx +0 -55
  69. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -19
  70. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -35
  71. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  72. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -19
  73. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -32
  74. package/test/nextjs-test-projects/next-app-15-4-11/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  75. package/test/nextjs-test-projects/next-app-15-4-11/src/app/revalidation-interface.tsx +0 -267
  76. package/test/nextjs-test-projects/next-app-15-4-11/tsconfig.json +0 -27
  77. package/test/nextjs-test-projects/next-app-16-0-11/README.md +0 -36
  78. package/test/nextjs-test-projects/next-app-16-0-11/eslint.config.mjs +0 -18
  79. package/test/nextjs-test-projects/next-app-16-0-11/next.config.ts +0 -10
  80. package/test/nextjs-test-projects/next-app-16-0-11/package.json +0 -28
  81. package/test/nextjs-test-projects/next-app-16-0-11/pnpm-lock.yaml +0 -4163
  82. package/test/nextjs-test-projects/next-app-16-0-11/postcss.config.mjs +0 -7
  83. package/test/nextjs-test-projects/next-app-16-0-11/src/app/api/cached-static-fetch/route.ts +0 -18
  84. package/test/nextjs-test-projects/next-app-16-0-11/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -27
  85. package/test/nextjs-test-projects/next-app-16-0-11/src/app/api/revalidatePath/route.ts +0 -15
  86. package/test/nextjs-test-projects/next-app-16-0-11/src/app/api/revalidateTag/route.ts +0 -20
  87. package/test/nextjs-test-projects/next-app-16-0-11/src/app/api/revalidated-fetch/route.ts +0 -17
  88. package/test/nextjs-test-projects/next-app-16-0-11/src/app/api/uncached-fetch/route.ts +0 -15
  89. package/test/nextjs-test-projects/next-app-16-0-11/src/app/favicon.ico +0 -0
  90. package/test/nextjs-test-projects/next-app-16-0-11/src/app/globals.css +0 -26
  91. package/test/nextjs-test-projects/next-app-16-0-11/src/app/layout.tsx +0 -59
  92. package/test/nextjs-test-projects/next-app-16-0-11/src/app/page.tsx +0 -755
  93. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -19
  94. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -34
  95. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  96. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/no-fetch/default-page/page.tsx +0 -55
  97. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -19
  98. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -35
  99. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  100. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -19
  101. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -32
  102. package/test/nextjs-test-projects/next-app-16-0-11/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  103. package/test/nextjs-test-projects/next-app-16-0-11/src/app/revalidation-interface.tsx +0 -267
  104. package/test/nextjs-test-projects/next-app-16-0-11/src/app/update-tag-test/page.tsx +0 -25
  105. package/test/nextjs-test-projects/next-app-16-0-11/tsconfig.json +0 -34
  106. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/README.md +0 -36
  107. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/cache-handler.js +0 -3
  108. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/eslint.config.mjs +0 -18
  109. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/next.config.ts +0 -15
  110. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/package.json +0 -28
  111. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/pnpm-lock.yaml +0 -4206
  112. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/postcss.config.mjs +0 -7
  113. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/public/file.svg +0 -1
  114. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/public/globe.svg +0 -1
  115. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/public/next.svg +0 -1
  116. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/public/vercel.svg +0 -1
  117. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/public/window.svg +0 -1
  118. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/cached-static-fetch/route.ts +0 -19
  119. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/cached-with-cachelife/route.ts +0 -24
  120. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/cached-with-tag/route.ts +0 -21
  121. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/expire-matrix/revalidate/route.ts +0 -34
  122. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/expire-matrix/route.ts +0 -23
  123. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/revalidate-tag/route.ts +0 -19
  124. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/api/revalidated-fetch/route.ts +0 -19
  125. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/cachelife-short/page.tsx +0 -110
  126. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/page.tsx +0 -112
  127. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/revalidate-durations/page.tsx +0 -106
  128. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/runtime-data-suspense/page.tsx +0 -127
  129. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/stale-while-revalidate/page.tsx +0 -130
  130. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/tag-invalidation/page.tsx +0 -127
  131. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/use-cache-nondeterministic/page.tsx +0 -110
  132. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/cache-lab/use-cache-remote/page.tsx +0 -85
  133. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/favicon.ico +0 -0
  134. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/globals.css +0 -26
  135. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/layout.tsx +0 -57
  136. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/page.tsx +0 -755
  137. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/revalidation-interface.tsx +0 -267
  138. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/src/app/update-tag-test/page.tsx +0 -22
  139. package/test/nextjs-test-projects/next-app-16-0-11-cache-components/tsconfig.json +0 -34
  140. package/test/nextjs-test-projects/next-app-16-2-6/README.md +0 -36
  141. package/test/nextjs-test-projects/next-app-16-2-6/eslint.config.mjs +0 -18
  142. package/test/nextjs-test-projects/next-app-16-2-6/next.config.ts +0 -7
  143. package/test/nextjs-test-projects/next-app-16-2-6/package.json +0 -28
  144. package/test/nextjs-test-projects/next-app-16-2-6/pnpm-lock.yaml +0 -4165
  145. package/test/nextjs-test-projects/next-app-16-2-6/postcss.config.mjs +0 -7
  146. package/test/nextjs-test-projects/next-app-16-2-6/src/app/api/cached-static-fetch/route.ts +0 -18
  147. package/test/nextjs-test-projects/next-app-16-2-6/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -27
  148. package/test/nextjs-test-projects/next-app-16-2-6/src/app/api/revalidatePath/route.ts +0 -15
  149. package/test/nextjs-test-projects/next-app-16-2-6/src/app/api/revalidateTag/route.ts +0 -20
  150. package/test/nextjs-test-projects/next-app-16-2-6/src/app/api/revalidated-fetch/route.ts +0 -17
  151. package/test/nextjs-test-projects/next-app-16-2-6/src/app/api/uncached-fetch/route.ts +0 -15
  152. package/test/nextjs-test-projects/next-app-16-2-6/src/app/favicon.ico +0 -0
  153. package/test/nextjs-test-projects/next-app-16-2-6/src/app/globals.css +0 -26
  154. package/test/nextjs-test-projects/next-app-16-2-6/src/app/layout.tsx +0 -59
  155. package/test/nextjs-test-projects/next-app-16-2-6/src/app/page.tsx +0 -755
  156. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -19
  157. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -34
  158. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  159. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/no-fetch/default-page/page.tsx +0 -55
  160. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -19
  161. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -35
  162. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  163. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -19
  164. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -32
  165. package/test/nextjs-test-projects/next-app-16-2-6/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  166. package/test/nextjs-test-projects/next-app-16-2-6/src/app/revalidation-interface.tsx +0 -267
  167. package/test/nextjs-test-projects/next-app-16-2-6/src/app/update-tag-test/page.tsx +0 -25
  168. package/test/nextjs-test-projects/next-app-16-2-6/tsconfig.json +0 -34
  169. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/README.md +0 -36
  170. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/cache-handler.js +0 -3
  171. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/eslint.config.mjs +0 -18
  172. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/next.config.ts +0 -15
  173. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/package.json +0 -28
  174. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/pnpm-lock.yaml +0 -4165
  175. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/postcss.config.mjs +0 -7
  176. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/public/file.svg +0 -1
  177. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/public/globe.svg +0 -1
  178. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/public/next.svg +0 -1
  179. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/public/vercel.svg +0 -1
  180. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/public/window.svg +0 -1
  181. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/cached-static-fetch/route.ts +0 -19
  182. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/cached-with-cachelife/route.ts +0 -24
  183. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/cached-with-tag/route.ts +0 -21
  184. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/expire-matrix/revalidate/route.ts +0 -34
  185. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/expire-matrix/route.ts +0 -23
  186. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/revalidate-tag/route.ts +0 -19
  187. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/api/revalidated-fetch/route.ts +0 -19
  188. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/cachelife-short/page.tsx +0 -110
  189. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/page.tsx +0 -112
  190. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/revalidate-durations/page.tsx +0 -106
  191. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/runtime-data-suspense/page.tsx +0 -127
  192. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/stale-while-revalidate/page.tsx +0 -130
  193. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/tag-invalidation/page.tsx +0 -127
  194. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/use-cache-nondeterministic/page.tsx +0 -110
  195. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/cache-lab/use-cache-remote/page.tsx +0 -85
  196. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/favicon.ico +0 -0
  197. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/globals.css +0 -26
  198. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/layout.tsx +0 -57
  199. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/page.tsx +0 -755
  200. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/revalidation-interface.tsx +0 -267
  201. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/src/app/update-tag-test/page.tsx +0 -22
  202. package/test/nextjs-test-projects/next-app-16-2-6-cache-components/tsconfig.json +0 -34
  203. package/test/nextjs-test-projects/next-app-16-3-0/README.md +0 -36
  204. package/test/nextjs-test-projects/next-app-16-3-0/eslint.config.mjs +0 -18
  205. package/test/nextjs-test-projects/next-app-16-3-0/next.config.ts +0 -7
  206. package/test/nextjs-test-projects/next-app-16-3-0/package.json +0 -28
  207. package/test/nextjs-test-projects/next-app-16-3-0/pnpm-lock.yaml +0 -4284
  208. package/test/nextjs-test-projects/next-app-16-3-0/postcss.config.mjs +0 -7
  209. package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/cached-static-fetch/route.ts +0 -18
  210. package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/nested-fetch-in-api-route/revalidated-fetch/route.ts +0 -27
  211. package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/revalidatePath/route.ts +0 -15
  212. package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/revalidateTag/route.ts +0 -20
  213. package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/revalidated-fetch/route.ts +0 -17
  214. package/test/nextjs-test-projects/next-app-16-3-0/src/app/api/uncached-fetch/route.ts +0 -15
  215. package/test/nextjs-test-projects/next-app-16-3-0/src/app/favicon.ico +0 -0
  216. package/test/nextjs-test-projects/next-app-16-3-0/src/app/globals.css +0 -26
  217. package/test/nextjs-test-projects/next-app-16-3-0/src/app/layout.tsx +0 -59
  218. package/test/nextjs-test-projects/next-app-16-3-0/src/app/page.tsx +0 -755
  219. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/cached-static-fetch/default--force-dynamic-page/page.tsx +0 -19
  220. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/cached-static-fetch/revalidate15--default-page/page.tsx +0 -34
  221. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/cached-static-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  222. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/no-fetch/default-page/page.tsx +0 -55
  223. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/revalidated-fetch/default--force-dynamic-page/page.tsx +0 -19
  224. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/revalidated-fetch/revalidate15--default-page/page.tsx +0 -35
  225. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/revalidated-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  226. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/uncached-fetch/default--force-dynamic-page/page.tsx +0 -19
  227. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/uncached-fetch/revalidate15--default-page/page.tsx +0 -32
  228. package/test/nextjs-test-projects/next-app-16-3-0/src/app/pages/uncached-fetch/revalidate15--force-dynamic-page/page.tsx +0 -25
  229. package/test/nextjs-test-projects/next-app-16-3-0/src/app/revalidation-interface.tsx +0 -267
  230. package/test/nextjs-test-projects/next-app-16-3-0/src/app/update-tag-test/page.tsx +0 -25
  231. package/test/nextjs-test-projects/next-app-16-3-0/tsconfig.json +0 -34
  232. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/README.md +0 -36
  233. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/cache-handler.js +0 -3
  234. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/eslint.config.mjs +0 -18
  235. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/next.config.ts +0 -15
  236. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/package.json +0 -28
  237. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/pnpm-lock.yaml +0 -4284
  238. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/postcss.config.mjs +0 -7
  239. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/file.svg +0 -1
  240. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/globe.svg +0 -1
  241. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/next.svg +0 -1
  242. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/vercel.svg +0 -1
  243. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/public/window.svg +0 -1
  244. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/cached-static-fetch/route.ts +0 -19
  245. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/cached-with-cachelife/route.ts +0 -24
  246. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/cached-with-tag/route.ts +0 -21
  247. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/expire-matrix/revalidate/route.ts +0 -34
  248. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/expire-matrix/route.ts +0 -23
  249. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/revalidate-tag/route.ts +0 -19
  250. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/api/revalidated-fetch/route.ts +0 -19
  251. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/cachelife-short/page.tsx +0 -110
  252. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/page.tsx +0 -112
  253. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/revalidate-durations/page.tsx +0 -106
  254. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/runtime-data-suspense/page.tsx +0 -127
  255. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/stale-while-revalidate/page.tsx +0 -130
  256. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/tag-invalidation/page.tsx +0 -127
  257. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/use-cache-nondeterministic/page.tsx +0 -110
  258. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/cache-lab/use-cache-remote/page.tsx +0 -85
  259. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/favicon.ico +0 -0
  260. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/globals.css +0 -26
  261. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/layout.tsx +0 -57
  262. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/page.tsx +0 -755
  263. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/revalidation-interface.tsx +0 -267
  264. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/src/app/update-tag-test/page.tsx +0 -22
  265. package/test/nextjs-test-projects/next-app-16-3-0-cache-components/tsconfig.json +0 -34
  266. package/test/nextjs-test-projects/next-app-customized/README.md +0 -36
  267. package/test/nextjs-test-projects/next-app-customized/customized-cache-handler.js +0 -34
  268. package/test/nextjs-test-projects/next-app-customized/eslint.config.mjs +0 -16
  269. package/test/nextjs-test-projects/next-app-customized/next.config.js +0 -6
  270. package/test/nextjs-test-projects/next-pages-16-2-6/README.md +0 -16
  271. package/test/nextjs-test-projects/next-pages-16-2-6/eslint.config.mjs +0 -18
  272. package/test/nextjs-test-projects/next-pages-16-2-6/next.config.ts +0 -7
  273. package/test/nextjs-test-projects/next-pages-16-2-6/package.json +0 -26
  274. package/test/nextjs-test-projects/next-pages-16-2-6/pnpm-lock.yaml +0 -3896
  275. package/test/nextjs-test-projects/next-pages-16-2-6/src/pages/api/revalidate.ts +0 -24
  276. package/test/nextjs-test-projects/next-pages-16-2-6/src/pages/index.tsx +0 -11
  277. package/test/nextjs-test-projects/next-pages-16-2-6/src/pages/isr/[slug].tsx +0 -49
  278. package/test/nextjs-test-projects/next-pages-16-2-6/src/pages/static-forever.tsx +0 -20
  279. package/test/nextjs-test-projects/next-pages-16-2-6/tsconfig.json +0 -34
  280. package/test/nextjs-test-projects/next-pages-16-3-0/README.md +0 -16
  281. package/test/nextjs-test-projects/next-pages-16-3-0/eslint.config.mjs +0 -18
  282. package/test/nextjs-test-projects/next-pages-16-3-0/next.config.ts +0 -7
  283. package/test/nextjs-test-projects/next-pages-16-3-0/package.json +0 -26
  284. package/test/nextjs-test-projects/next-pages-16-3-0/pnpm-lock.yaml +0 -3939
  285. package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/api/revalidate.ts +0 -24
  286. package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/index.tsx +0 -11
  287. package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/isr/[slug].tsx +0 -49
  288. package/test/nextjs-test-projects/next-pages-16-3-0/src/pages/static-forever.tsx +0 -20
  289. package/test/nextjs-test-projects/next-pages-16-3-0/tsconfig.json +0 -34
  290. package/test/playwright/cache-lab.spec.ts +0 -232
  291. package/test/playwright/update-tag.spec.ts +0 -33
  292. package/test/vitest/integration/build-id-prefix.integration.test.ts +0 -102
  293. package/test/vitest/integration/cache-components/cache-components.integration.test.ts +0 -389
  294. package/test/vitest/integration/cache-components/redis-kill-reconnect.test.ts +0 -65
  295. package/test/vitest/integration/cache-components/redis-quit-vs-disconnect.test.ts +0 -59
  296. package/test/vitest/integration/cache-components/redis-subscriber-outage.test.ts +0 -100
  297. package/test/vitest/integration/cache-components/scripts/redis-kill-reconnect.ts +0 -243
  298. package/test/vitest/integration/cache-components/scripts/redis-quit-vs-disconnect.ts +0 -113
  299. package/test/vitest/integration/cache-components/scripts/redis-subscriber-outage.ts +0 -379
  300. package/test/vitest/integration/cache-components/scripts/redis-test-helpers.ts +0 -155
  301. package/test/vitest/integration/nextjs-cache-handler.integration.test.ts +0 -959
  302. package/test/vitest/integration/pages-router.integration.test.ts +0 -430
  303. package/test/vitest/unit/SyncedMap-orphan-cleanup.test.ts +0 -111
  304. package/test/vitest/unit/SyncedMap-reconnect-repro.test.ts +0 -154
  305. package/test/vitest/unit/cache-components-update-tags.test.ts +0 -350
  306. package/test/vitest/unit/cache-ttl.test.ts +0 -67
  307. package/test/vitest/unit/compare-and-unlink.test.ts +0 -22
  308. package/test/vitest/unit/index.test.ts +0 -190
  309. package/test/vitest/unit/pages-router-kinds.test.ts +0 -303
  310. package/test/vitest/unit/reconnect-socket-already-opened.test.ts +0 -117
  311. package/test/vitest/unit/redis-connection.test.ts +0 -39
  312. package/test/vitest/unit/serializer.test.ts +0 -182
  313. package/test/vitest/unit/tag-revalidation.test.ts +0 -178
  314. package/test/vitest/unit/utils/prefix.test.ts +0 -115
  315. package/tsconfig.json +0 -18
  316. package/tsup.config.ts +0 -14
  317. package/vite.config.ts +0 -34
  318. package/vitest.cache-components.config.ts +0 -16
@@ -1,379 +0,0 @@
1
- /**
2
- * Reproduces issue #86: Memory grows unbounded and process never recovers
3
- * after a short Redis outage — subscriber reconnect loop.
4
- *
5
- * This script creates two RedisStringsHandler instances (A and B) sharing
6
- * the same keyPrefix so their SyncedMaps communicate via Redis PubSub.
7
- * It also creates a CacheComponentsHandler singleton (C).
8
- *
9
- * Test sequence:
10
- * 1. Verify PubSub sync works before outage (A.set → B.sharedTagsMap.get)
11
- * 2. Verify subscriber clients have error listeners before outage
12
- * 3. Kill Redis, call get() 50× during outage (heap-growth probe)
13
- * 4. Wait 3 s for error handlers to fire and fail
14
- * 5. Count duplicate() calls during outage (client-leak probe)
15
- * 6. Restart Redis, wait for main clients to reconnect
16
- * 7. Verify PubSub sync works after outage (EXPECTED TO FAIL — the bug)
17
- * 8. Verify subscriber clients still have error listeners (EXPECTED TO FAIL)
18
- * 9. Verify get() works after Redis restart
19
- *
20
- * Output: lines of `RESULT|<name>|PASS|<detail>` or `RESULT|<name>|FAIL|<detail>`
21
- * followed by `RESULTS_JSON|<json>` on the last line.
22
- */
23
-
24
- import {
25
- detectContainerRuntime,
26
- getFreePort,
27
- sh,
28
- sleep,
29
- startRedis,
30
- waitUntil,
31
- type TestResult,
32
- } from './redis-test-helpers';
33
-
34
- // ---------------------------------------------------------------------------
35
- // Result tracking
36
- // ---------------------------------------------------------------------------
37
-
38
- const results: TestResult[] = [];
39
-
40
- function record(name: string, pass: boolean, detail: string) {
41
- results.push({ name, pass, detail });
42
- process.stdout.write(`RESULT|${name}|${pass ? 'PASS' : 'FAIL'}|${detail}\n`);
43
- }
44
-
45
- // ---------------------------------------------------------------------------
46
- // Main
47
- // ---------------------------------------------------------------------------
48
-
49
- async function main() {
50
- const runtime = detectContainerRuntime();
51
- const name = `redis-e2e-${Math.random().toString(36).slice(2, 8)}`;
52
- const port = await getFreePort();
53
-
54
- // cleanup any stale container
55
- sh(runtime, ['rm', '-f', name]);
56
-
57
- // 1. Start Redis
58
- startRedis(runtime, name, port);
59
-
60
- // Set env vars BEFORE importing so the CacheComponentsHandler singleton
61
- // picks up the correct Redis URL.
62
- process.env.REDIS_URL = `redis://127.0.0.1:${port}`;
63
- process.env.VERCEL_URL = `e2e-${name}-`;
64
-
65
- // Import handlers (dynamic import ensures env vars are set first)
66
- const { getRedisCacheComponentsHandler } = await import(
67
- '../../../../../src/CacheComponentsHandler'
68
- );
69
- const { default: RedisStringsHandler } = await import(
70
- '../../../../../src/RedisStringsHandler'
71
- );
72
-
73
- const socketOpts = {
74
- connectTimeout: 2_000,
75
- reconnectStrategy: (retries: number) => Math.min(50 + retries * 50, 500),
76
- };
77
-
78
- // 2. Create handler A (writer) and B (reader) with same keyPrefix
79
- const handlerA = new RedisStringsHandler({
80
- redisUrl: `redis://127.0.0.1:${port}`,
81
- socketOptions: socketOpts,
82
- keyPrefix: `e2e-${name}-`,
83
- killContainerOnErrorThreshold: 0, // disabled — same as issue #86 config
84
- } as any);
85
-
86
- const handlerB = new RedisStringsHandler({
87
- redisUrl: `redis://127.0.0.1:${port}`,
88
- socketOptions: socketOpts,
89
- keyPrefix: `e2e-${name}-`,
90
- killContainerOnErrorThreshold: 0,
91
- } as any);
92
-
93
- // CacheComponentsHandler singleton (created on import via redisCacheHandler)
94
- const handlerC = getRedisCacheComponentsHandler();
95
-
96
- // 3. Monkey-patch A's client.duplicate to count calls (client-leak probe)
97
- const clientA = (handlerA as any).client;
98
- const originalDuplicate = clientA.duplicate.bind(clientA);
99
- let duplicateCount = 0;
100
- (clientA as any).duplicate = function (...args: any[]) {
101
- duplicateCount++;
102
- return originalDuplicate(...args);
103
- };
104
-
105
- // 4. Wait for all main clients to be ready
106
- await waitUntil(async () => (handlerA as any).client.isReady, 20_000);
107
- await waitUntil(async () => (handlerB as any).client.isReady, 20_000);
108
- await waitUntil(async () => (handlerC as any).client.isReady, 20_000);
109
-
110
- // Record initial duplicate count (3 SyncedMaps × 1 duplicate each = 3)
111
- const initialDuplicateCount = duplicateCount;
112
-
113
- // 5. Test: PubSub sync works before outage
114
- await handlerA.set(
115
- 'key1',
116
- {
117
- kind: 'FETCH',
118
- data: {
119
- headers: {},
120
- body: Buffer.from('hello').toString('base64'),
121
- status: 200,
122
- url: 'https://example.com/e2e',
123
- },
124
- revalidate: 10,
125
- },
126
- { isRoutePPREnabled: false, isFallback: false, tags: ['tag1'] },
127
- );
128
-
129
- const pubsubInitial = await waitUntil(async () => {
130
- const tags = (handlerB as any).sharedTagsMap.get('key1');
131
- return !!tags && tags.length === 1 && tags[0] === 'tag1';
132
- }, 5_000);
133
-
134
- record(
135
- 'pubsub-initial-strings',
136
- pubsubInitial,
137
- pubsubInitial
138
- ? 'sync received — B.sharedTagsMap has key1'
139
- : 'B.sharedTagsMap never received sync for key1',
140
- );
141
-
142
- // 6. Test: Error listeners present before outage
143
- const subB = (handlerB as any).sharedTagsMap.subscriberClient;
144
- const subC = (handlerC as any).revalidatedTagsMap.subscriberClient;
145
- const initListenerB = subB?.listenerCount?.('error') ?? -1;
146
- const initListenerC = subC?.listenerCount?.('error') ?? -1;
147
-
148
- record(
149
- 'error-listener-initial',
150
- initListenerB >= 1 && initListenerC >= 1,
151
- `B.sharedTagsMap.subscriber listenerCount(error)=${initListenerB}, C.revalidatedTagsMap.subscriber listenerCount(error)=${initListenerC}`,
152
- );
153
-
154
- // 7. Kill Redis
155
- sh(runtime, ['stop', '-t', '0', name], { timeoutMs: 30_000 });
156
-
157
- // 8. Test: get() returns null during outage (symptom verification)
158
- // Use a key that was NOT just set() — the dedup cache seeds the return
159
- // value on set(), so get('key1') would return the cached value without
160
- // hitting Redis. Using a different key forces a real Redis GET which fails.
161
- let getDuringOutage = false;
162
- let getDuringOutageDetail = '';
163
- try {
164
- const result = await handlerA.get('nonexistent-during-outage', {
165
- kind: 'FETCH',
166
- revalidate: 10,
167
- fetchUrl: 'https://example.com/e2e',
168
- fetchIdx: 0,
169
- tags: ['tag1'],
170
- softTags: [],
171
- isFallback: false,
172
- });
173
- getDuringOutage = result === null;
174
- getDuringOutageDetail = getDuringOutage
175
- ? 'returned null (expected during outage)'
176
- : `returned ${typeof result}`;
177
- } catch (err: any) {
178
- getDuringOutageDetail = `threw: ${err?.message ?? err}`;
179
- }
180
- record('get-during-outage', getDuringOutage, getDuringOutageDetail);
181
-
182
- // 9. Test: Heap growth during outage
183
- const heapBefore = process.memoryUsage().heapUsed;
184
- for (let i = 0; i < 50; i++) {
185
- try {
186
- await handlerA.get(`nonexistent-${i}`, {
187
- kind: 'FETCH',
188
- revalidate: 10,
189
- fetchUrl: 'https://example.com/e2e',
190
- fetchIdx: 0,
191
- tags: ['tag1'],
192
- softTags: [],
193
- isFallback: false,
194
- });
195
- } catch {
196
- // ignore
197
- }
198
- }
199
- // Force a GC pass if --expose-gc is available so we measure retained memory
200
- if (typeof (globalThis as any).gc === 'function') {
201
- (globalThis as any).gc();
202
- }
203
- const heapAfter = process.memoryUsage().heapUsed;
204
- const heapGrowthMB = (heapAfter - heapBefore) / 1024 / 1024;
205
- record(
206
- 'heap-growth-during-outage',
207
- heapGrowthMB < 50,
208
- `heap grew ${heapGrowthMB.toFixed(2)} MB during 50 get() calls`,
209
- );
210
-
211
- // 10. Wait for subscriber error handlers to fire and fail
212
- await sleep(3_000);
213
-
214
- // 11. Test: Duplicate count during outage (client-leak probe)
215
- // This is informational: in some scenarios quit() throws before
216
- // duplicate() is reached (no leak), in others duplicate() runs but
217
- // setupPubSub() throws (leaked client). Either way the subscriber
218
- // is dead — the PubSub test below is the definitive check.
219
- const outageDuplicates = duplicateCount - initialDuplicateCount;
220
- record(
221
- 'duplicate-count-during-outage',
222
- true, // informational — always passes, detail has the count
223
- `${outageDuplicates} duplicate() calls during outage (initial=${initialDuplicateCount}, total=${duplicateCount})`,
224
- );
225
-
226
- // 12. Restart Redis
227
- startRedis(runtime, name, port);
228
-
229
- // 13. Wait for main clients to reconnect
230
- const reconnectedA = await waitUntil(async () => {
231
- try {
232
- return (await (handlerA as any).client.ping()) === 'PONG';
233
- } catch {
234
- return false;
235
- }
236
- }, 30_000);
237
-
238
- const reconnectedB = await waitUntil(async () => {
239
- try {
240
- return (await (handlerB as any).client.ping()) === 'PONG';
241
- } catch {
242
- return false;
243
- }
244
- }, 30_000);
245
-
246
- record(
247
- 'main-client-reconnects',
248
- reconnectedA && reconnectedB,
249
- `A reconnected=${reconnectedA}, B reconnected=${reconnectedB}`,
250
- );
251
-
252
- // Wait a bit for subscriber reconnection to complete
253
- await sleep(2_000);
254
-
255
- // 14. Test: PubSub sync after outage (was the bug — should now PASS)
256
- if (reconnectedA) {
257
- await handlerA.set(
258
- 'key2',
259
- {
260
- kind: 'FETCH',
261
- data: {
262
- headers: {},
263
- body: Buffer.from('world').toString('base64'),
264
- status: 200,
265
- url: 'https://example.com/e2e2',
266
- },
267
- revalidate: 10,
268
- },
269
- { isRoutePPREnabled: false, isFallback: false, tags: ['tag2'] },
270
- );
271
-
272
- // Give the subscriber reconnect loop time to succeed after Redis
273
- // restarts. The backoff delays are 500ms, 1s, 2s, 4s, 8s, capped at 10s.
274
- // After a 3s outage + restart, the subscriber may need up to ~10s to
275
- // reconnect depending on which backoff slot it's in.
276
- const pubsubAfter = await waitUntil(async () => {
277
- const tags = (handlerB as any).sharedTagsMap.get('key2');
278
- return !!tags && tags.length === 1 && tags[0] === 'tag2';
279
- }, 20_000);
280
-
281
- record(
282
- 'pubsub-after-outage-strings',
283
- pubsubAfter,
284
- pubsubAfter
285
- ? 'sync received — B.sharedTagsMap has key2'
286
- : 'B.sharedTagsMap never received sync for key2 (subscriber is dead)',
287
- );
288
- } else {
289
- record(
290
- 'pubsub-after-outage-strings',
291
- false,
292
- 'skipped — main client A did not reconnect',
293
- );
294
- }
295
-
296
- // 15. Test: Error listener on subscriber after outage
297
- // Informational: the listener may still be present on the old dead client
298
- // (if quit() threw before duplicate()), or may be missing (if duplicate()
299
- // ran but setupPubSub() threw). Either way, the subscriber is non-functional.
300
- // The definitive test is pubsub-after-outage-strings below.
301
- const subBAfter = (handlerB as any).sharedTagsMap.subscriberClient;
302
- const subCAfter = (handlerC as any).revalidatedTagsMap.subscriberClient;
303
- const afterListenerB = subBAfter?.listenerCount?.('error') ?? -1;
304
- const afterListenerC = subCAfter?.listenerCount?.('error') ?? -1;
305
- const sameClientB = subBAfter === subB;
306
- const sameClientC = subCAfter === subC;
307
-
308
- record(
309
- 'error-listener-after-outage',
310
- true, // informational — always passes, detail has the counts
311
- `B: listenerCount(error)=${afterListenerB} (was ${initListenerB}), sameClient=${sameClientB}; C: listenerCount(error)=${afterListenerC} (was ${initListenerC}), sameClient=${sameClientC}`,
312
- );
313
-
314
- // 16. Test: get() works after Redis restart (main client path)
315
- // Redis was restarted with --rm (data lost), so re-seed key1 first
316
- // to verify the main client can write and read after restart.
317
- let getAfter = false;
318
- let getAfterDetail = '';
319
- try {
320
- await handlerA.set(
321
- 'key1',
322
- {
323
- kind: 'FETCH',
324
- data: {
325
- headers: {},
326
- body: Buffer.from('hello').toString('base64'),
327
- status: 200,
328
- url: 'https://example.com/e2e',
329
- },
330
- revalidate: 10,
331
- },
332
- { isRoutePPREnabled: false, isFallback: false, tags: ['tag1'] },
333
- );
334
- const result = await handlerA.get('key1', {
335
- kind: 'FETCH',
336
- revalidate: 10,
337
- fetchUrl: 'https://example.com/e2e',
338
- fetchIdx: 0,
339
- tags: ['tag1'],
340
- softTags: [],
341
- isFallback: false,
342
- });
343
- getAfter = result !== null;
344
- getAfterDetail = getAfter
345
- ? 'returned cached value'
346
- : 'returned null (cache miss or stale)';
347
- } catch (err: any) {
348
- getAfterDetail = `threw: ${err?.message ?? err}`;
349
- }
350
- record('get-after-outage', getAfter, getAfterDetail);
351
-
352
- // 17. Test: Total duplicate count (informational)
353
- record(
354
- 'duplicate-count-total',
355
- true, // informational — always passes, detail has the count
356
- `total duplicate() calls=${duplicateCount} (initial=${initialDuplicateCount}, extra=${duplicateCount - initialDuplicateCount})`,
357
- );
358
-
359
- // 18. Cleanup
360
- try {
361
- await (handlerA as any).client?.quit?.();
362
- } catch {}
363
- try {
364
- await (handlerB as any).client?.quit?.();
365
- } catch {}
366
- try {
367
- await (handlerC as any).client?.quit?.();
368
- } catch {}
369
- sh(runtime, ['rm', '-f', name]);
370
-
371
- // Output JSON summary for the vitest wrapper to parse
372
- process.stdout.write(`RESULTS_JSON|${JSON.stringify(results)}\n`);
373
- process.exit(0);
374
- }
375
-
376
- main().catch((err) => {
377
- console.error(err);
378
- process.exit(1);
379
- });
@@ -1,155 +0,0 @@
1
- import { spawn, spawnSync } from 'child_process';
2
-
3
- export type ContainerRuntime = 'podman' | 'docker';
4
-
5
- export function canRun(cmd: string): boolean {
6
- const res = spawnSync(cmd, ['--version'], {
7
- encoding: 'utf8',
8
- timeout: 3_000,
9
- });
10
- return !res.error && (res.status ?? 1) === 0;
11
- }
12
-
13
- export function hasContainerRuntime(): boolean {
14
- return canRun('podman') || canRun('docker');
15
- }
16
-
17
- export function detectContainerRuntime(): ContainerRuntime {
18
- if (process.env.CONTAINER_RUNTIME === 'podman') return 'podman';
19
- if (process.env.CONTAINER_RUNTIME === 'docker') return 'docker';
20
- if (canRun('podman')) return 'podman';
21
- if (canRun('docker')) return 'docker';
22
- throw new Error(
23
- 'Neither podman nor docker is available. Install one of them or set CONTAINER_RUNTIME.',
24
- );
25
- }
26
-
27
- export interface ShResult {
28
- code: number;
29
- stdout: string;
30
- stderr: string;
31
- }
32
-
33
- export function sh(
34
- cmd: string,
35
- args: string[],
36
- opts: { timeoutMs?: number } = {},
37
- ): ShResult {
38
- const res = spawnSync(cmd, args, {
39
- encoding: 'utf8',
40
- timeout: opts.timeoutMs ?? 30_000,
41
- });
42
- if (res.error) throw res.error;
43
- return {
44
- code: res.status ?? -1,
45
- stdout: res.stdout ?? '',
46
- stderr: res.stderr ?? '',
47
- };
48
- }
49
-
50
- export async function sleep(ms: number): Promise<void> {
51
- await new Promise((r) => setTimeout(r, ms));
52
- }
53
-
54
- export async function waitUntil(
55
- fn: () => Promise<boolean>,
56
- timeoutMs = 20_000,
57
- intervalMs = 200,
58
- ): Promise<boolean> {
59
- const start = Date.now();
60
- // eslint-disable-next-line no-constant-condition
61
- while (true) {
62
- if (await fn()) return true;
63
- if (Date.now() - start > timeoutMs) return false;
64
- await sleep(intervalMs);
65
- }
66
- }
67
-
68
- export async function getFreePort(): Promise<number> {
69
- const net = await import('net');
70
- return new Promise((resolve, reject) => {
71
- const srv = net.createServer();
72
- srv.on('error', reject);
73
- srv.listen(0, '127.0.0.1', () => {
74
- const addr = srv.address();
75
- if (!addr || typeof addr === 'string')
76
- return reject(new Error('bad addr'));
77
- const p = addr.port;
78
- srv.close(() => resolve(p));
79
- });
80
- });
81
- }
82
-
83
- export function startRedis(
84
- runtime: ContainerRuntime,
85
- name: string,
86
- port: number,
87
- ): void {
88
- const r = sh(
89
- runtime,
90
- [
91
- 'run',
92
- '-d',
93
- '--rm',
94
- '--name',
95
- name,
96
- '-p',
97
- `${port}:6379`,
98
- 'docker.io/redis:7-alpine',
99
- 'redis-server',
100
- '--notify-keyspace-events',
101
- 'Exe',
102
- ],
103
- { timeoutMs: 60_000 },
104
- );
105
- if (r.code !== 0) throw new Error(`${runtime} run failed: ${r.stderr}`);
106
- }
107
-
108
- export interface TestResult {
109
- name: string;
110
- pass: boolean;
111
- detail: string;
112
- }
113
-
114
- export function record(name: string, pass: boolean, detail: string): void {
115
- process.stdout.write(`RESULT|${name}|${pass ? 'PASS' : 'FAIL'}|${detail}\n`);
116
- }
117
-
118
- export function parseResults(stdout: string): Map<string, TestResult> {
119
- const map = new Map<string, TestResult>();
120
- for (const line of stdout.split('\n')) {
121
- const m = line.match(/^RESULT\|([^|]+)\|(PASS|FAIL)\|(.*)$/);
122
- if (m) {
123
- map.set(m[1], {
124
- name: m[1],
125
- pass: m[2] === 'PASS',
126
- detail: m[3],
127
- });
128
- }
129
- }
130
- return map;
131
- }
132
-
133
- export function runNode(
134
- script: string,
135
- timeoutMs = 300_000,
136
- ): Promise<{ code: number; stdout: string; stderr: string }> {
137
- return new Promise((resolve, reject) => {
138
- const p = spawn('pnpm', ['-s', 'tsx', script], {
139
- stdio: ['ignore', 'pipe', 'pipe'],
140
- env: { ...process.env },
141
- });
142
- let stdout = '';
143
- let stderr = '';
144
- p.stdout.on('data', (d) => (stdout += d.toString()));
145
- p.stderr.on('data', (d) => (stderr += d.toString()));
146
- const t = setTimeout(() => {
147
- p.kill('SIGKILL');
148
- reject(new Error('timeout'));
149
- }, timeoutMs);
150
- p.on('close', (code) => {
151
- clearTimeout(t);
152
- resolve({ code: code ?? -1, stdout, stderr });
153
- });
154
- });
155
- }