Skip to content

fix(tech-detect): read every use of a component ref that is next/script somewhere on the page #1487 - #1490

Closed
nc9 wants to merge 1 commit into
mainfrom
fix/flight-script-ref-1487
Closed

nc9 wants to merge 1 commit into
mainfrom
fix/flight-script-ref-1487

Conversation

@nc9

@nc9 nc9 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1487. (#1480 has merged; this is on main.)

#1487's residual: a Clarity loader in a Next.js layout <head> that the reader skipped. Evidence: a masked row from a real corpus site shows the layout passing the Clarity loader as a bare { "type": "text/javascript", "children": "<snippet>" } beside two uses of the same component reference that carry src plus strategy: "afterInteractive" and id plus strategy plus children; the loader use has no id and no strategy, and the reference resolves to a numeric module id with no path. The earlier \\\" was only JSON escaping.

  • Pass 1 in flightLoaderText: the refs that are next/script somewhere on the page, i.e. any use with a strategy that is one of the four next/script takes (afterInteractive, lazyOnload, beforeInteractive, worker). Only rows that mention "strategy" are parsed for it, so a payload without one pays a substring search. Pass 2 (unchanged) then reads every use of such a ref as a script: src, __html, children, with the data-type check. Tighter than accepting a bare { type, children } by shape: a ref never seen with a strategy is not read, and a lookalike component's own strategy prop (not one of the four) does not promote it.
  • Regression coverage (no code change): a JSON row right after a text row with no newline between them is parsed correctly by the byte-length reader (parseRows is unchanged); tested with ASCII and multi-byte text.
  • Tests (10 new in flight-script-narrow-1437.test.ts, 58 in the file; the two positives fail without the promotion): the bare instance is read whichever order the three uses come in; a JSON row right after a text row; a ref never seen with script props that shows a code sample is not read; a lookalike strategy does not promote; a code sample in a pre and a data-typed use stay dropped; 20,000 refs, half with script props, stay under 1 s (about 170 ms measured). The fix(tech-detect): read a long next/script snippet kept in a Next.js flight text row #1477 #1480 amplification and the tech-detect: a Next.js flight script re-opens the prose, link and metadata false-positive classes for script-url signatures #1437 negatives still pass; the other flight, markup and bundle suites pass; tsgo is clean.
  • Docs sentence and CHANGELOG (Unreleased / Fixed). Synthetic hosts and a fake loader only.

Review round 1: tests that kill the pass-1 guards: once the node budget is spent no later row is parsed for pass 1 (JSON.parse is spied: 3 calls, not 53), a strategy use nested past the depth guard does not promote its ref while one 10 levels deep does, and only rows that mention a strategy are parsed (103 parses for 100 plain rows, not 203). Pass 1 now ends at its budget for the page, not per row. Rebased onto main as a single commit (the #1480 commits are in main).

Skill: no change needed.

nik

@nc9
nc9 changed the base branch from fix/flight-text-rows-1477 to main November 1, 2026 03:14
@nc9
nc9 force-pushed the fix/flight-script-ref-1487 branch from 6fbe6e0 to 71ab480 Compare November 1, 2026 06:08
@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.155 as 3c25da17 via #1503.

nik

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.

1 participant