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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `~<major>.<minor>.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.
Expand Down Expand Up @@ -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 `~<major>.<minor>.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
Expand Down
4 changes: 4 additions & 0 deletions docs/publishing/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
`~<major>.<minor>.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
Expand Down
2 changes: 1 addition & 1 deletion packages/cache-handler/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
22 changes: 22 additions & 0 deletions scripts/release-version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down
15 changes: 15 additions & 0 deletions scripts/release-version.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
peerMismatch,
peerRange,
pickTarget,
preReleaseOfReleased,
releaseChangelog,
usedVersions,
} from "./release-version.mjs";
Expand Down Expand Up @@ -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/);
});
Loading