Skip to content

fix(tech-detect): read only the script elements of a Next.js flight script #1437 - #1442

Closed
nc9 wants to merge 1 commit into
mainfrom
fix/flight-script-narrow-1437
Closed

nc9 wants to merge 1 commit into
mainfrom
fix/flight-script-narrow-1437

Conversation

@nc9

@nc9 nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1437.

A Next.js App Router flight script (self.__next_f.push) was read as one block of text so the layout's next/script loader is found. That also matched a vendor URL the page only renders as content (JSON-LD sameAs, meta description, CSP meta, <a href>, prose).

  • New packages/tech-detect/src/flight.ts: decodes the push([1,"..."]) chunks of ALL the page's flight scripts together (a production build splits them over many <script> elements and cuts rows mid-row), parses the rows and reads only src, dangerouslySetInnerHTML.__html and string children of a script element or of a next/script component. The component is identified by its props (strategy; or id with __html or code-like children; or a src), because a production build names it $L2 with a numeric module id and no next/script path (the dev path form still counts). Data script types and every other element's props are not read. Bounded: 2 MB per script, 8 MB per page, depth 64, 400k nodes; no regex over the payload.
  • A flight-shaped script with no push([1,"..."]) chunk is read as an ordinary script (16 KB cap). self.__next_s is read like any ordinary inline script (16 KB cap).
  • Tests: flight-script-narrow-1437.test.ts (34). Committed fixtures in tests/fixtures/next-build/ are real next build output (Next 15.5 and 14.2, App Router, production) with build hashes replaced: afterInteractive children, lazyOnload __html, lazyOnload src, body-placed, Next 14, beforeInteractive inline and src, plain inline, and a 139 KB page with JSON-LD sameAs, link, meta and prose naming the vendor (no loader: not detected; with the loader: detected). 8 of the tests fail on the previous head of this PR. Synthetic cases cover each negative, split chunks, hostile payloads.
  • Docs sentence about the flight exception replaced; CHANGELOG under Unreleased / Fixed.

The prior head of this PR lost the production next/script loader (review: real Next 14 and 15 builds); this head fixes that and tests against real build output. The prose-children heuristic (id plus code-like children) is the one judgement call; a corpus run before release is still worthwhile.

Skill: no change needed.

nik

…cript, not its whole text #1437

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tech-detect: a Next.js flight script re-opens the prose, link and metadata false-positive classes for script-url signatures

1 participant