From 6debd62326ad32880ca5f7b0779ca1a4202cb83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 15 Nov 2026 23:40:31 +0100 Subject: [PATCH] build(deps): bump next and eslint-config-next to 16.4.6 16.4.6 keeps a single header value as a string, so the compression middleware now sees a route handler's Content-Type and gzips the response when the client accepts it. Route handlers were never compressed before. Measured on a production build: JSON and CSV exports go out gzipped with their Content-Disposition intact and still flush chunk by chunk, so a streamed download keeps arriving as it is written. The Coach and document chat streams send Cache-Control: no-transform, which the middleware honours, so they stay uncompressed and each frame arrives when it is written. A guard now holds every text/event-stream surface to that directive. The notification journey failed twice on the release candidate at the same step: the e-mail address typed into the card was wiped. The spec waited for the settings read with waitForResponse, which settles on the headers, and treated that as the card having copied the server value into the input. With compression the body follows the headers after a round through zlib on the thread pool, which a loaded runner can hold up, and the late copy overwrote the typed value. The spec now also waits for each card's enable switch, which is disabled until its read has landed and is enabled in the same render that does the copy. --- CHANGELOG.md | 7 ++ e2e/notification-dispatch-journey.spec.ts | 13 ++- package.json | 4 +- pnpm-lock.yaml | 104 +++++++++---------- src/__tests__/sse-no-transform-guard.test.ts | 64 ++++++++++++ 5 files changed, 136 insertions(+), 56 deletions(-) create mode 100644 src/__tests__/sse-no-transform-guard.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fde94601..9a0a6ab71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## [Unreleased] +### Changed + +- API responses and CSV or JSON exports now go out gzip-compressed when the + browser or app asks for it, which comes with Next.js 16.4.6. The live Coach + and document chat streams are left uncompressed, so their text still + arrives as it is written. + ### Security - The container image moves to Node 22.23.5, a security release with fixes diff --git a/e2e/notification-dispatch-journey.spec.ts b/e2e/notification-dispatch-journey.spec.ts index 97d583b91..385ffc8bb 100644 --- a/e2e/notification-dispatch-journey.spec.ts +++ b/e2e/notification-dispatch-journey.spec.ts @@ -217,8 +217,15 @@ async function attemptCount(page: Page): Promise { * sync-from-server shape, no effect involved. A value typed into the input * before that copy runs is silently replaced by the server's, so the save that * follows persists an empty field and the next request is refused for a reason - * that points nowhere near the test. Waiting for the two reads is what makes - * the copy already done rather than pending. + * that points nowhere near the test. + * + * Waiting for the two reads alone is not enough. Playwright settles a + * response on its headers, and the body can follow later: API responses are + * compressed, and the compressed body reaches the socket only after a round + * through zlib on the thread pool, which a loaded runner can hold up. The copy + * runs only once the body is parsed. Each card keeps its enable switch + * disabled until its read has landed and does the copy in that same render, + * so an enabled switch is the signal that the seed is in the input. */ async function openChannels(page: Page): Promise { const seeded = ["/api/settings/email", "/api/settings/ntfy"].map((endpoint) => @@ -231,6 +238,8 @@ async function openChannels(page: Page): Promise { await page.goto("/settings/integrations", { waitUntil: "domcontentloaded" }); await expect(page.locator(CHANNELS_PANEL)).toBeVisible({ timeout: 30_000 }); await Promise.all(seeded); + await expect(page.locator("#email-toggle")).toBeEnabled(); + await expect(page.locator("#ntfy-toggle")).toBeEnabled(); } /** diff --git a/package.json b/package.json index d7b49d5ba..92c3c5b0b 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "jspdf-autotable": "^5.0.9", "lucide-react": "^1.72.0", "mmdb-lib": "^3.0.5", - "next": "16.4.5", + "next": "16.4.6", "nodemailer": "10.5.0", "otpauth": "^9.6.0", "p-limit": "^7.3.3", @@ -125,7 +125,7 @@ "@vitest/coverage-v8": "^5.1.0", "ajv": "^8.20.0", "eslint": "^9", - "eslint-config-next": "16.4.5", + "eslint-config-next": "16.4.6", "fast-check": "4.10.2", "knip": "^6.45.1", "lefthook": "^2.2.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2e7c06a7d..e0ba48c0c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,8 +125,8 @@ importers: specifier: ^3.0.5 version: 3.0.5 next: - specifier: 16.4.5 - version: 16.4.5(@babel/core@7.29.7(supports-color@7.2.0))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.0)(@types/node@26.6.6)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + specifier: 16.4.6 + version: 16.4.6(@babel/core@7.29.7(supports-color@7.2.0))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.0)(@types/node@26.6.6)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) nodemailer: specifier: 10.5.0 version: 10.5.0 @@ -255,8 +255,8 @@ importers: specifier: ^9 version: 9.39.3(jiti@2.7.0)(supports-color@7.2.0) eslint-config-next: - specifier: 16.4.5 - version: 16.4.5(@typescript-eslint/parser@8.71.0(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3) + specifier: 16.4.6 + version: 16.4.6(@typescript-eslint/parser@8.71.0(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3) fast-check: specifier: 4.10.2 version: 4.10.2 @@ -1332,60 +1332,60 @@ packages: '@next/bundle-analyzer@16.4.6': resolution: {integrity: sha512-Evp2ETZoDcqpg5LZPeJNG51o1Bc5vH+LPSP+BmSkdjeykMCh1fMB/shs3bJVbTOxYp7wC3Ed3HLo0jgX1BdxNA==} - '@next/env@16.4.5': - resolution: {integrity: sha512-JwSPwpdkZL5VMl2jA/q+JI8MZdweAL3xmw5/tb9y/TLtmS0YXZnmYDzSihwk8xTj1OL+WM53gTqaj96yuLp6Xw==} + '@next/env@16.4.6': + resolution: {integrity: sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==} - '@next/eslint-plugin-next@16.4.5': - resolution: {integrity: sha512-dNmc4y4En/34tWxaBFF2tG/R9GeiRwVPf7v8Az/Pqk8FcT4Uv0ePmrZKvWBL2nFy1QprPgJW+6XjfyV6jbRV3Q==} + '@next/eslint-plugin-next@16.4.6': + resolution: {integrity: sha512-HdqERVOafOD8JaUSAkwf9aSu/1rsHlkN8C5GcXYBH3C/z1MxBhZFxB5rz/xqMMRiIj7r9tIv8OCLQ9JWUxCvWA==} - '@next/swc-darwin-arm64@16.4.5': - resolution: {integrity: sha512-W5TniBzWKASbNNwHZ/S/f1MxQUXU/LdjklVMWA0Ujbfl7SZnUzFls45hO0i/sF7Bx1jJBWp7WWmoQajXtX/O8A==} + '@next/swc-darwin-arm64@16.4.6': + resolution: {integrity: sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@next/swc-darwin-x64@16.4.5': - resolution: {integrity: sha512-uWq4qkHapBDS1oFltWS4YxTb9pLHAtLNcpbuK6SmRsebLYZqpBML/j/C0op+50JYGTpZgVL/DWNt/6oWlamrrw==} + '@next/swc-darwin-x64@16.4.6': + resolution: {integrity: sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@next/swc-linux-arm64-gnu@16.4.5': - resolution: {integrity: sha512-FdRcyOx5u5P51mlAqLB9EXdd8jZO5fsdHtk4BAQSkqOywCsbTNN/rmw+jO7pnmjNdAtu2AG46NzbCL2FPDrrgw==} + '@next/swc-linux-arm64-gnu@16.4.6': + resolution: {integrity: sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [glibc] - '@next/swc-linux-arm64-musl@16.4.5': - resolution: {integrity: sha512-cyvmmgtRXR8aGVT86wi9Py53IlfyCx7P2fZxuAXAoTummDnhKtUyjrMeXfapqp4qgD+gT5RqyGD/VfA16jEK7Q==} + '@next/swc-linux-arm64-musl@16.4.6': + resolution: {integrity: sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [musl] - '@next/swc-linux-x64-gnu@16.4.5': - resolution: {integrity: sha512-hPc+Fl+N22DAvqZHq559NmamXboOX5Lu8I5Wl0DezfrhTk1Zz21NQeYoZDmNI/NjTcrdsVxM72Fzn2lI+Q+vAw==} + '@next/swc-linux-x64-gnu@16.4.6': + resolution: {integrity: sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [glibc] - '@next/swc-linux-x64-musl@16.4.5': - resolution: {integrity: sha512-gbACYE8IP/jlprNTpiWXHb8N9CofOzpnEwH2SrIz1dUbiJf1FbDssDupCAPeP1Taxe8mgG20sGZamJI7KFOdZw==} + '@next/swc-linux-x64-musl@16.4.6': + resolution: {integrity: sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [musl] - '@next/swc-win32-arm64-msvc@16.4.5': - resolution: {integrity: sha512-+8gj++ZMo8H20Xh2ijjNqyFk5LPLw0AC4Fs4Tq/G94rjjQXhOjN4jgSWsWKPFsyY26hfIeemJIwKtMxOsp5GBA==} + '@next/swc-win32-arm64-msvc@16.4.6': + resolution: {integrity: sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@next/swc-win32-x64-msvc@16.4.5': - resolution: {integrity: sha512-qNZj66pYXnaWLiF9R9GUbfBdrCv7kC6TaZfIwB2KH5WPc/8pEM3nVOj8hpQhWJU8S94rlH5MPDcX15+RrgUhiw==} + '@next/swc-win32-x64-msvc@16.4.6': + resolution: {integrity: sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -4275,8 +4275,8 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - eslint-config-next@16.4.5: - resolution: {integrity: sha512-mvh39zYLoNjpT5tVmf8xZu7i5lEOb5jN5cW6qD9OpeCp4GEEOeYta0Z2XyKiD0pYdlvm5/Td6Bi890maPRlIjg==} + eslint-config-next@16.4.6: + resolution: {integrity: sha512-IBGGrVf9E6pL0NGL0hmeicVGeSyv1VEzIWq6IecDqkw+YFByhEtDJS9u1r6s6a1VxK6rssh69KyNFQUgfaacqw==} peerDependencies: eslint: '>=9.0.0' typescript: '>=3.3.1' @@ -5532,8 +5532,8 @@ packages: resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==} engines: {node: '>= 0.6'} - next@16.4.5: - resolution: {integrity: sha512-rmdfsWosjTUO+6R0S3KokoIk6Kj0sWDRTe86tZHdqaWH/oXq/udX3/4xb+YQi7aWbyEFoglDU54kaifLCdXbBw==} + next@16.4.6: + resolution: {integrity: sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==} engines: {node: '>=20.9.0'} hasBin: true peerDependencies: @@ -8422,37 +8422,37 @@ snapshots: - bufferutil - utf-8-validate - '@next/env@16.4.5': {} + '@next/env@16.4.6': {} - '@next/eslint-plugin-next@16.4.5(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))': + '@next/eslint-plugin-next@16.4.6(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))': dependencies: '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0)) fast-glob: 3.3.1 transitivePeerDependencies: - eslint - '@next/swc-darwin-arm64@16.4.5': + '@next/swc-darwin-arm64@16.4.6': optional: true - '@next/swc-darwin-x64@16.4.5': + '@next/swc-darwin-x64@16.4.6': optional: true - '@next/swc-linux-arm64-gnu@16.4.5': + '@next/swc-linux-arm64-gnu@16.4.6': optional: true - '@next/swc-linux-arm64-musl@16.4.5': + '@next/swc-linux-arm64-musl@16.4.6': optional: true - '@next/swc-linux-x64-gnu@16.4.5': + '@next/swc-linux-x64-gnu@16.4.6': optional: true - '@next/swc-linux-x64-musl@16.4.5': + '@next/swc-linux-x64-musl@16.4.6': optional: true - '@next/swc-win32-arm64-msvc@16.4.5': + '@next/swc-win32-arm64-msvc@16.4.6': optional: true - '@next/swc-win32-x64-msvc@16.4.5': + '@next/swc-win32-x64-msvc@16.4.6': optional: true '@noble/hashes@2.4.0': {} @@ -11458,9 +11458,9 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-next@16.4.5(@typescript-eslint/parser@8.71.0(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3): + eslint-config-next@16.4.6(@typescript-eslint/parser@8.71.0(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3))(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3): dependencies: - '@next/eslint-plugin-next': 16.4.5(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0)) + '@next/eslint-plugin-next': 16.4.6(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0)) eslint: 9.39.3(jiti@2.7.0)(supports-color@7.2.0) eslint-import-resolver-node: 0.3.10(supports-color@7.2.0) eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.3(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) @@ -12165,7 +12165,7 @@ snapshots: is-bun-module@2.0.0: dependencies: - semver: 7.8.5 + semver: 7.8.6 is-callable@1.2.7: {} @@ -12746,9 +12746,9 @@ snapshots: negotiator@1.0.0: {} - next@16.4.5(@babel/core@7.29.7(supports-color@7.2.0))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.0)(@types/node@26.6.6)(react-dom@19.3.1(react@19.3.1))(react@19.3.1): + next@16.4.6(@babel/core@7.29.7(supports-color@7.2.0))(@opentelemetry/api@1.9.1)(@playwright/test@1.65.0)(@types/node@26.6.6)(react-dom@19.3.1(react@19.3.1))(react@19.3.1): dependencies: - '@next/env': 16.4.5 + '@next/env': 16.4.6 '@swc/helpers': 0.5.23 baseline-browser-mapping: 2.11.27 caniuse-lite: 1.0.30001815 @@ -12757,14 +12757,14 @@ snapshots: react-dom: 19.3.1(react@19.3.1) styled-jsx: 5.1.6(@babel/core@7.29.7(supports-color@7.2.0))(react@19.3.1) optionalDependencies: - '@next/swc-darwin-arm64': 16.4.5 - '@next/swc-darwin-x64': 16.4.5 - '@next/swc-linux-arm64-gnu': 16.4.5 - '@next/swc-linux-arm64-musl': 16.4.5 - '@next/swc-linux-x64-gnu': 16.4.5 - '@next/swc-linux-x64-musl': 16.4.5 - '@next/swc-win32-arm64-msvc': 16.4.5 - '@next/swc-win32-x64-msvc': 16.4.5 + '@next/swc-darwin-arm64': 16.4.6 + '@next/swc-darwin-x64': 16.4.6 + '@next/swc-linux-arm64-gnu': 16.4.6 + '@next/swc-linux-arm64-musl': 16.4.6 + '@next/swc-linux-x64-gnu': 16.4.6 + '@next/swc-linux-x64-musl': 16.4.6 + '@next/swc-win32-arm64-msvc': 16.4.6 + '@next/swc-win32-x64-msvc': 16.4.6 '@opentelemetry/api': 1.9.1 '@playwright/test': 1.65.0 sharp: 0.35.5(@types/node@26.6.6) @@ -13721,7 +13721,7 @@ snapshots: dependencies: '@img/colour': 1.1.0 detect-libc: 2.1.2 - semver: 7.8.5 + semver: 7.8.6 optionalDependencies: '@img/sharp-darwin-arm64': 0.35.5 '@img/sharp-darwin-x64': 0.35.5 diff --git a/src/__tests__/sse-no-transform-guard.test.ts b/src/__tests__/sse-no-transform-guard.test.ts new file mode 100644 index 000000000..8cc207454 --- /dev/null +++ b/src/__tests__/sse-no-transform-guard.test.ts @@ -0,0 +1,64 @@ +/** + * Every response this app streams as Server-Sent Events says + * `Cache-Control: no-transform`. + * + * Next.js compresses route-handler responses for a client that accepts it + * (since 16.4.6), and its compression middleware skips a response only when + * the type is not compressible or `Cache-Control` carries `no-transform`. + * `text/event-stream` is compressible, so without the directive a Coach or + * document-chat stream would go out gzipped: every token a separate deflate + * flush, and a proxy that buffers compressed bodies would hold the reply until + * it ends. The directive is what keeps the stream as written. + * + * The guard finds the SSE surfaces by the content type they declare, so a new + * one is covered without being listed, and it fails if it finds none, which + * would mean the matcher went blind rather than that the surfaces went away. + */ +import { describe, expect, it } from "vitest"; +import { join } from "node:path"; + +import { + readSourceText, + stripComments, + walkSourceFiles, +} from "./helpers/source-files"; + +const SRC = join(process.cwd(), "src"); + +/** A `Content-Type` header literal (either quote style) naming SSE. */ +const SSE_CONTENT_TYPE = /["']?content-type["']?\s*:\s*["']text\/event-stream/i; +/** A `Cache-Control` header literal whose value lists `no-transform`. */ +const NO_TRANSFORM = + /["']?cache-control["']?\s*:\s*["'][^"']*\bno-transform\b/i; + +function sseSurfaces(): string[] { + return walkSourceFiles(SRC, { floor: 3000 }) + .filter((p) => !p.startsWith("generated/")) + .filter((p) => !p.includes("__tests__")) + .filter((p) => !p.endsWith(".test.ts") && !p.endsWith(".test.tsx")) + .filter((p) => + SSE_CONTENT_TYPE.test(stripComments(readSourceText(join(SRC, p)), p)), + ) + .sort(); +} + +describe("SSE responses opt out of compression", () => { + it("finds the SSE surfaces it is meant to watch", () => { + // The Coach turn and the fenced document chat today. + const surfaces = sseSurfaces(); + expect(surfaces.length).toBeGreaterThanOrEqual(2); + expect(surfaces).toEqual( + expect.arrayContaining([ + "lib/ai/coach/turn/sse.ts", + "lib/documents/fenced-chat.ts", + ]), + ); + }); + + it("sets Cache-Control: no-transform wherever it declares text/event-stream", () => { + const missing = sseSurfaces().filter( + (p) => !NO_TRANSFORM.test(stripComments(readSourceText(join(SRC, p)), p)), + ); + expect(missing).toEqual([]); + }); +});