From c26af9e44dae3390010d87ac1b85953b1f392474 Mon Sep 17 00:00:00 2001 From: Jason Roy Date: Tue, 3 Nov 2026 09:50:14 -0800 Subject: [PATCH] fix: move post-16.4.3 changes out of the released 16.4.3 changelog 16.4.3-rc.5 and rc.6 were cut after 16.4.3 shipped. The release script filed their Unreleased entries into the published 16.4.3 section, and semver sorts those RCs below 16.4.3, so latest installs never got the #104 fix. With main on a pre-release, the daily loop also skipped the Next 16.4.4 bump. - CHANGELOG: the post-16.4.3 entries go back under [Unreleased], with a note on the peer pin; the 16.4.3 section is again what shipped. - package.json: back to 16.4.3, the last release, so the loop bumps to 16.4.4. - release-version.mjs: check --unused refuses a pre-release of a published version, and sync refuses to add a pre-release to a dated section. - RELEASE.md: an RC is for the next unreleased version. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 46 ++++++++++++++++------------- docs/publishing/RELEASE.md | 4 +++ packages/cache-handler/package.json | 2 +- scripts/release-version.mjs | 22 ++++++++++++++ scripts/release-version.test.mjs | 15 ++++++++++ 5 files changed, 68 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67d4e70..71ed2ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,32 @@ All notable changes to this project will be documented in this file. This project follows [Semantic Versioning](https://semver.org/). +## [Unreleased] + +Two cache fixes, one opt-in option, and a stricter install check. Nothing to change in your +config. Release candidates 16.4.3-rc.5 and rc.6 carried these changes; they sort below 16.4.3 on +npm, so `latest` and `^16.4.3` installs never got them. + +> **Install check.** npm now refuses (`ERESOLVE`) to install this handler with a Next.js minor +> other than its own. Upgrade the handler and Next.js together, and install with `--save-exact`. + +### Fixed + +- Page-cache entries now retain their request's first lookup timestamp, preventing a render + completed after a tag invalidation from caching its old content as fresh. The production + e2e matrix holds a render across invalidation, including two processes sharing Redis. +- Data-cache reads enforce the exact render-start hard-expiry deadline in memory, Redis and + outage fallback, including when rendering finishes between whole seconds. + +### Added + +- `withCache(config, { useCache: "redis" })` shares plain `"use cache"` entries across instances. + The default remains memory; explicit `handlers.default` takes precedence. + +### Changed + +- **The handler is pinned to your Next.js minor.** The `next` peer dependency (it was `^16.0.0`) is now `~..0` of this release's own version (for example `~16.4.0` for 16.4.x, `~16.5.0` for 16.5.x). The package version follows Next.js, and the 16.5 releases remove the APIs deprecated in 16.4.3, so npm now refuses to install a handler whose minor does not match your Next.js (an `ERESOLVE` error) instead of pairing handler 16.5.x with Next 16.4; pnpm and Yarn warn. Each new Next minor moves the peer with it. Install with `--save-exact` and upgrade the handler and Next.js together. + ## [16.4.3] - 2026-10-26 **This is a major release under a patch number.** The package version follows Next.js, so the work that went into the 16.4.3 release candidates ships as 16.4.3, and every install on `^16.4.2` or `~16.4.2` gets it on its next update. A 16.4.2 setup keeps working on Node 22.3+ (and, for the page handler, Redis 6.2+ with Lua scripting): deprecated APIs still run, log a one-time warning, and are removed in 16.5. @@ -119,26 +145,6 @@ For anyone who tested `16.4.3-rc.3` or earlier. What to change for `16.4.3-rc.4` - `RedisCacheHandler` accepts any non-number `defaultTTL` with a warning instead of throwing; negative and infinite numbers still throw. The details are under "Deprecated" above. - The 16.4.2 APIs log a one-time deprecation warning and are removed in 16.5 (earlier candidates said "on the Next 17 line", and rc.4 said "16.5.0", a version npm can no longer publish). -### Fixed - -- Page-cache entries now retain their request's first lookup timestamp, preventing a render - completed after a tag invalidation from caching its old content as fresh. The production - e2e matrix holds a render across invalidation, including two processes sharing Redis. - -### Changed - -- **The handler is pinned to your Next.js minor.** The `next` peer dependency (it was `^16.0.0`) is now `~..0` of this release's own version (for example `~16.4.0` for 16.4.x, `~16.5.0` for 16.5.x). The package version follows Next.js, and the 16.5 releases remove the APIs deprecated in 16.4.3, so npm now refuses to install a handler whose minor does not match your Next.js (an `ERESOLVE` error) instead of pairing handler 16.5.x with Next 16.4; pnpm and Yarn warn. Each new Next minor moves the peer with it. Install with `--save-exact` and upgrade the handler and Next.js together. - -### Added - -- `withCache(config, { useCache: "redis" })` shares plain `"use cache"` entries across instances. - The default remains memory; explicit `handlers.default` takes precedence. - -### Fixed - -- Data-cache reads enforce the exact render-start hard-expiry deadline in memory, Redis and - outage fallback, including when rendering finishes between whole seconds. - ## [16.0.0] - 2025-11-18 ### Added diff --git a/docs/publishing/RELEASE.md b/docs/publishing/RELEASE.md index 657838b..98ae1bd 100644 --- a/docs/publishing/RELEASE.md +++ b/docs/publishing/RELEASE.md @@ -19,6 +19,10 @@ The package's major.minor follows Next.js; the patch number is ours. - **An RC is graduated by hand.** While the package is on a pre-release (e.g. `16.4.3-rc.0` on staging), the loop bumps nothing, so it can never publish that untested code to `latest` by itself. Bump to the final version once the RC has been proven. +- **An RC is for the next unreleased version.** Once 16.4.3 is published, the next RC is + `16.4.4-rc.0`, never `16.4.3-rc.5`: semver sorts that below 16.4.3, so `latest` and `^16.4.3` + installs never get it, and its notes would land in the published 16.4.3 section. + `release-version.mjs check --unused` (every bump and tag) and `sync` refuse it. - **The handler is pinned to the app's Next.js minor.** The `next` peer dependency is `~..0` for the package's major.minor (an RC counts by its base version), so npm refuses to pair handler 16.5.x with Next 16.4 (`ERESOLVE`). It is `~X.Y.0`, not an exact diff --git a/packages/cache-handler/package.json b/packages/cache-handler/package.json index e260d39..2f4a1a7 100644 --- a/packages/cache-handler/package.json +++ b/packages/cache-handler/package.json @@ -1,6 +1,6 @@ { "name": "@mrjasonroy/cache-components-cache-handler", - "version": "16.4.3-rc.6", + "version": "16.4.3", "description": "Cache handler for Next.js 16+ with support for 'use cache' directive and Cache Components", "author": "Jason Roy", "license": "MIT", diff --git a/scripts/release-version.mjs b/scripts/release-version.mjs index 4d036b3..33ee93f 100644 --- a/scripts/release-version.mjs +++ b/scripts/release-version.mjs @@ -90,6 +90,21 @@ export function pickTarget(next, current, used) { return target; } +/** + * An error message when `version` is a pre-release of a version npm has already seen, else + * `null`. 16.4.3-rc.5 after 16.4.3 sorts below 16.4.3, so `latest` and `^16.4.3` never get it, + * and its release notes would land in the published 16.4.3 section. + */ +export function preReleaseOfReleased(version, used) { + const { major, minor, patch, pre } = parseVersion(version); + const base = `${major}.${minor}.${patch}`; + if (!pre.length || !used.has(base)) return null; + return ( + `${version} is a pre-release of ${base}, which is already published: it sorts below ${base}, ` + + `so no install on latest gets it. Use a pre-release of the next patch (${major}.${minor}.${patch + 1}-${pre.join(".")}).` + ); +} + /** An error message when `pkg`'s major.minor is ahead of Next's `next`, else `null`. */ export function aheadOfNext(pkg, next) { const p = parseVersion(pkg); @@ -163,6 +178,11 @@ export function releaseChangelog(text, version, date) { const body = out.slice(bodyStart, bodyEnd); const rest = out.slice(0, start) + out.slice(bodyEnd); const existing = existingRe.exec(rest); + if (existing && pre.length && /\d{4}-\d{2}-\d{2}/.test(existing[1]) && body.trim()) { + throw new Error( + `CHANGELOG.md: ## [${base}] is already released (dated); ${version} must not add to it`, + ); + } if (existing && !body.trim()) { out = rest; } else if (existing) { @@ -206,6 +226,8 @@ function main(argv) { if (peer) throw new Error(peer); if (arg === "--unused") { const used = usedVersions(JSON.parse(npmView(pkg.name, "time", "--json"))); + const stale = preReleaseOfReleased(pkg.version, used); + if (stale) throw new Error(stale); if (used.has(pkg.version)) { const where = `\`npm view ${pkg.name} time\`, unpublished versions included`; throw new Error( diff --git a/scripts/release-version.test.mjs b/scripts/release-version.test.mjs index 423fdac..8940376 100644 --- a/scripts/release-version.test.mjs +++ b/scripts/release-version.test.mjs @@ -8,6 +8,7 @@ import { peerMismatch, peerRange, pickTarget, + preReleaseOfReleased, releaseChangelog, usedVersions, } from "./release-version.mjs"; @@ -163,3 +164,17 @@ test("merging into the last section of the file keeps one trailing newline", () "# Changelog\n\n## [16.4.4]\n\nIntro.\n\n- First.\n\n- Second.\n", ); }); + +test("a pre-release of a published version is refused", () => { + const used = usedVersions({ "16.4.3": "2026-10-27T00:00:00.000Z", "16.4.3-rc.4": "x" }); + assert.match(preReleaseOfReleased("16.4.3-rc.5", used), /16\.4\.4-rc\.5/); + assert.equal(preReleaseOfReleased("16.4.4-rc.0", used), null); + assert.equal(preReleaseOfReleased("16.4.3", used), null); + assert.equal(preReleaseOfReleased("16.4.3-rc.4", usedVersions({ "16.4.3-rc.3": "x" })), null); +}); + +test("releaseChangelog refuses to add a pre-release to a dated section", () => { + const text = "# Changelog\n\n## [Unreleased]\n\n- New\n\n## [16.4.3] - 2026-10-26\n\n- Old\n"; + assert.throws(() => releaseChangelog(text, "16.4.3-rc.5", "2026-11-03"), /already released/); + assert.match(releaseChangelog(text, "16.4.4-rc.0", "2026-11-03"), /## \[16\.4\.4\]\n\n- New/); +});