From a41c054b48d48f9baeea50138df889c2f6a5ee6b Mon Sep 17 00:00:00 2001 From: Shogo256 Date: Sun, 15 Nov 2026 18:04:37 +0900 Subject: [PATCH 1/3] Make Decoder ambient, add Unknown.of, and say where SEAM2001's Unknown came from A boundary is already a Decoder value that `decode b from ...` accepts, so a generic fetch-and-decode function was possible, but the type had to be imported and the README never showed it. Decoder now needs no import, like SeamResponse. Unknown.of(value) marks a value as outside data for tests, replacing `as unknown as Unknown`. It is the identity at run time. SEAM2001 now names the value holding the Unknown data and its origin, followed through consts in the same file (`in `text` (from `res.text()`, line 12)`), or the path into a value that holds it (`in `res.json()` (`res` is SeamResponse)`). The SeamResponse hint also shows for `Response | undefined`. --- CHANGELOG.md | 15 +++ DECISIONS.md | 9 ++ README.md | 26 ++++ packages/compiler/src/checker.ts | 123 ++++++++++++++++-- packages/compiler/src/program.ts | 9 +- packages/compiler/src/transform.ts | 3 +- packages/compiler/test/checker.test.ts | 62 ++++++++- .../golden/expected/cases/diagnostics.txt | 8 +- .../test/golden/expected/demo/diagnostics.txt | 2 +- packages/runtime/README.md | 2 +- packages/runtime/src/unknown.ts | 8 ++ packages/runtime/test/decoder.test.ts | 12 ++ packages/ts-plugin/src/index.ts | 12 +- packages/ts-plugin/test/plugin.test.ts | 4 + 14 files changed, 274 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0a0898..0512dd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ All `@seamscript/*` packages and `create-seamscript` are released together, with one version number. Releases are on GitHub: https://github.com/Shogo256/SeamScript/releases +## Unreleased + +### Added + +- **`Decoder` needs no import**, like `SeamResponse`. A boundary is a value of this type, and `decode b from json text` already took one in place of a type name, so a single `get(b: Decoder, url)` can fetch and check any boundary; but the type had to be imported from `@seamscript/runtime`, and the README never showed it. Found by an app that wrote the same fetch-and-decode function once per boundary. +- **`Unknown.of(value)`** marks a value as outside data, for tests: `decode Order from Unknown.of({ ... })` is checked exactly like a response body. Before, tests needed `as unknown as Unknown`. It is an identity function at run time and is allowed everywhere, as marking a value Unknown only takes uses away. + +### Changed + +- **SEAM2001 says which value holds the Unknown data and where it came from.** ``Unknown data in `text` (from `res.text()`, line 12) cannot flow into string here``; for a value that holds Unknown inside it, the place: ``Unknown data in `res.json()` (`res` is SeamResponse) cannot flow into ...``. The origin follows `const` declarations in the same file. Before, the message only said "Unknown data", which was confusing when the value was a `SeamResponse`, not Unknown itself. + +### Fixed + +- **The hint to type a variable `SeamResponse` was missing for `Response | undefined`**, the usual type of a variable declared before a `try`. It now shows whenever the destination's type includes the lib's `Response`, and says what to write instead of telling the reader to decode. + ## 0.1.2 ### Added diff --git a/DECISIONS.md b/DECISIONS.md index 61675cf..d8c5788 100644 --- a/DECISIONS.md +++ b/DECISIONS.md @@ -366,6 +366,15 @@ Found by the first production app (CS Pro's chat widget), which asks a server th - **SEAM1403 checks only what it can see.** A `fetch` in a latest function's body (including nested callbacks) with no init, or with an object-literal init without `signal`, is reported. An init in a variable, or a literal with a spread, is not: the checker can't tell what is in it, and a false error would teach people to silence the check. Any `signal` property counts (`AbortSignal.any([signal, ...])` is legitimate). - **`poll` is a runtime function, not language.** Polling has no data that needs the compiler: the reads are ordinary (decode, Result). It runs one read at a time instead of on a fixed timer, so a slow server is never hit by overlapping reads; backs off only on failure; and pauses while the page is hidden, because a background tab polling every few minutes, in every tab a user keeps open, is load nobody sees. Long polling, SSE and debounce stay out: no app here needs them yet. +## Passing boundaries and outside data around (after 0.1.2) + +Raised by a user's list of language proposals. Of the five, two already worked and only needed to be shown (a boundary as a `Decoder` argument; Unknown in fields, arrays and parameters typed Unknown), one was already the design (`SeamResponse` passes freely; only the lib's `Response` is refused), and two were new: + +- **No `Boundary` type or new syntax for generic decoding.** A boundary's constant is already a `Decoder`, and `decode b from ...` already accepts a value there (the transform emits `__decode(b, v)` for any expression). Making `Decoder` ambient was enough. +- **The line stays at "losing the mark", not "carrying it".** Carrying Unknown in places typed Unknown was always allowed (the outflow allowlist); what is refused is any place that would let it be read without decode. The lib's `Response` is one: its `json()` is `any`. +- **`Unknown.of` is not restricted to tests.** Going from a value to Unknown can only remove uses, so it opens no hole; a warning outside tests would need a notion of "test file" the compiler does not have, for no safety gain. It is easy to find by name. +- **SEAM2001's origin is followed through `const` declarations in the same file only.** A `let` may have been reassigned, and a parameter's origin is at each call site; naming a wrong origin would be worse than naming none. The line is filled in by the caller (`withOriginLine`), as only `seamc` and the editor plugin can map positions in the transformed file back to the source. The path into a value that holds Unknown (`res.json()`, `box.inner[i]`) is found by the same walk as `mentionsUnknown`, through unions, awaited types, array elements, properties and call results. + ## Open questions ### From the demonstration diff --git a/README.md b/README.md index 7663eee..4bc6f34 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,32 @@ The common web APIs are sources already. Declare your own in `tsconfig.json`, as With `"externalAny": "unknown"`, a value whose declared type is `any` in a package's type declarations (`axios`'s `response.data`, for example) is reported where it is used, with a quick fix that decodes it. +### Passing boundaries and outside data around + +A boundary is also a value, of type `Decoder`, so one function can fetch and check any of them. `decode` takes it in place of a type name, and `Decoder` needs no import: + +```ts +async function get(b: Decoder, url: string): Promise> { + const res = await fetch(url); + return decode b from json await res.text(); +} + +const order = await get(Order, `/orders/${id}`); +``` + +Unknown can be carried anywhere its type says `Unknown`: a field (`{ body: Unknown; at: number }`), an array (`Unknown[]`), a parameter (`(raw: Unknown) => ...`) or a return value. What is stopped is losing the mark (`unknown`, `any`, `as`, a template string, ...), not carrying the value. `fetch`'s result is a `SeamResponse`, which can be passed and returned like any value; only a place typed with the lib's `Response` is an error, because its `json()` would hand the data out as `any`. + +In tests, `Unknown.of(value)` marks a value as outside data, so it is checked exactly as a response body would be, without a cast: + +```ts +const r = decode Order from Unknown.of({ id: "1", status: "paid" }); // checked like a response body +expect(r.ok).toBe(false); // id must be an Int64, total is missing, ... +``` + +`Unknown.of` changes nothing at run time. It is allowed in any file: marking a value Unknown only takes uses away from it. + +When Unknown data goes somewhere it may not, SEAM2001 says which value holds it and where it came from: ``Unknown data in `text` (from `res.text()`, line 12) cannot flow into string here``, or, for a value that holds Unknown inside it, ``Unknown data in `res.json()` (`res` is SeamResponse) cannot flow into Response | undefined here``. + ### Value constraints A boundary field's type can be followed by constraints, checked when the value is decoded (and by `encode`, which throws `EncodeRangeError` for a value that would not decode again): diff --git a/packages/compiler/src/checker.ts b/packages/compiler/src/checker.ts index d6bec4e..335f11b 100644 --- a/packages/compiler/src/checker.ts +++ b/packages/compiler/src/checker.ts @@ -31,6 +31,19 @@ export interface Finding { fix?: Fix; /** Not a diagnostic: a fix for TypeScript's own error `code` over this span. */ fixOnly?: boolean; + /** + * Where the Unknown data in a SEAM2001 came from, in the transformed file. Its + * line in the source goes where `message` holds ORIGIN_LINE (see `withOriginLine`). + */ + origin?: number; +} + +/** Stands in a finding's message for ", line N" of its `origin`, which only the caller can map to the source. */ +export const ORIGIN_LINE = "\u0000origin-line\u0000"; + +/** A finding's message with its origin's 1-based source line filled in (or left out when unknown). */ +export function withOriginLine(message: string, line: number | undefined): string { + return message.replace(ORIGIN_LINE, line === undefined ? "" : `, line ${line}`); } /** Edits in the transformed file's positions, all within text kept from the source. */ @@ -395,13 +408,14 @@ export function createChecker(ts: typeof import("typescript"), options: CheckerO const ENV_HINT = " To check one variable, decode it: `const port = decode Int64 from process.env.PORT`, then `port.ok`; a variable that isn't set fails to decode (actual: \"undefined\")."; - const report = (node: ts.Node, code: string, message: string, fix?: Fix) => + const report = (node: ts.Node, code: string, message: string, fix?: Fix, origin?: number) => findings.push({ pos: node.getStart(file), end: node.getEnd(), code, message: code === Codes.unknownFlow && isWholeProcessEnv(node) ? message + ENV_HINT : message, ...(fix ? { fix } : {}), + ...(origin !== undefined ? { origin } : {}), }); // ---- Fixes ------------------------------------------------------------------------- @@ -577,7 +591,94 @@ export function createChecker(ts: typeof import("typescript"), options: CheckerO const hasUnknown = (node: ts.Expression) => containsUnknown(typeOf(node)) || narrowedUnknown(node); const narrowedMessage = "Unknown data stays Unknown after a type guard such as `typeof`; decode it instead (`decode T from ...`)."; - const exitMessage = (what: string) => `Unknown data cannot be ${what}; decode it first (\`decode T from ...\`).`; + // ---- Where the Unknown data is, for messages --------------------------------------- + + /** Source text on one line, shortened: messages quote it. */ + const quote = (node: ts.Node, max = 40): string => { + const text = node.getText(file).replace(/\s+/g, " "); + return text.length > max ? `${text.slice(0, max - 1)}…` : text; + }; + + /** The value itself, without parentheses, `await`, `!` or the compiler's Unknown marker. */ + const bare = (e: ts.Expression): ts.Expression => { + for (;;) { + if (ts.isParenthesizedExpression(e) || ts.isAwaitExpression(e) || ts.isNonNullExpression(e)) e = e.expression; + else if (ts.isCallExpression(e) && ts.isIdentifier(e.expression) && e.expression.text.startsWith("__unknown") && e.arguments[0]) e = e.arguments[0]; + else return e; + } + }; + + /** The expression a `const` got its value from, followed through other consts: `text` in `const text = await res.text()` → `res.text()`. */ + const originOf = (expr: ts.Expression): ts.Expression | undefined => { + let origin: ts.Expression | undefined; + let e = bare(expr); + for (let i = 0; i < 8 && ts.isIdentifier(e); i++) { + const decl = checker.getSymbolAtLocation(e)?.valueDeclaration; + if (decl === undefined || !ts.isVariableDeclaration(decl) || !ts.isIdentifier(decl.name) || decl.initializer === undefined) break; + if (decl.getSourceFile() !== file || !(ts.getCombinedNodeFlags(decl) & ts.NodeFlags.Const)) break; + e = origin = bare(decl.initializer); + } + return origin; + }; + + /** Where in a value of type `t` its Unknown is, as an access: "" (it is Unknown), ".json()", "[i].body"; undefined if not found. */ + const unknownPath = (t: ts.Type, depth = 0): string | undefined => { + if (depth > 6 || !containsUnknown(t)) return undefined; + if (brandOf(t) === "Unknown") return ""; + if (t.isUnionOrIntersection()) { + for (const m of t.types) { + const p = unknownPath(m, depth + 1); + if (p !== undefined) return p; + } + return undefined; + } + if (!(t.flags & ts.TypeFlags.Object)) return undefined; + const awaited = checker.getAwaitedType(t); + if (awaited !== undefined && awaited !== t) return unknownPath(awaited, depth + 1); + if (checker.isArrayLikeType(t)) { + const element = checker.getIndexTypeOfType(t, ts.IndexKind.Number); + const p = element && unknownPath(element, depth + 1); + return p === undefined ? undefined : `[i]${p}`; + } + for (const prop of checker.getPropertiesOfType(t)) { + if (typeof prop.escapedName === "string" && prop.escapedName.startsWith("__")) continue; + const p = unknownPath(checker.getTypeOfSymbol(prop), depth + 1); + if (p !== undefined) return `.${prop.name}${p}`; + } + for (const sig of t.getCallSignatures()) { + const p = unknownPath(sig.getReturnType(), depth + 1); + if (p !== undefined) return `()${p}`; + } + return undefined; + }; + + /** + * Which value holds the Unknown data and where it came from, for a message: + * " in `text` (from `res.text()`, line 12)", " from `e.data`", + * " in `res.json()` (`res` is SeamResponse)". + */ + const placeOf = (expr: ts.Expression): { text: string; origin?: number } => { + const e = bare(expr); + const name = quote(e); + const type = typeOf(expr); + const path = unknownPath(type); + if (path === "") { + const origin = originOf(expr); + if (origin !== undefined) return { text: ` in \`${name}\` (from \`${quote(origin)}\`${ORIGIN_LINE})`, origin: origin.getStart(file) }; + return { text: ts.isIdentifier(e) ? ` in \`${name}\`` : ` from \`${name}\`` }; + } + const shown = show(type); + const typeText = shown.length > 60 ? `${shown.slice(0, 59)}…` : shown; + if (path === undefined) return { text: ` in \`${name}\` (${typeText})` }; + return { text: ` in \`${name.length > 30 ? "…" : name}${path}\` (\`${name}\` is ${typeText})` }; + }; + + const exitMessage = (what: string, place = "") => `Unknown data${place} cannot be ${what}; decode it first (\`decode T from ...\`).`; + /** Reports `node` for letting out the Unknown data in `expr` (by default, `node` itself). */ + const reportExit = (node: ts.Node, what: string, expr: ts.Expression) => { + const place = placeOf(expr); + report(node, Codes.unknownFlow, exitMessage(what, place.text), undefined, place.origin); + }; /** * A value flowing into the place its contextual type describes. Returns whether @@ -611,8 +712,13 @@ export function createChecker(ts: typeof import("typescript"), options: CheckerO if (!absorbs(source, target)) return false; // The lib's Response would let json() escape as any: the usual cause is a // variable typed for fetch's result, so say what to write instead. - const responseHint = show(target) === "Response" ? " `fetch` returns a SeamResponse, whose json() stays Unknown: type the variable `SeamResponse`." : ""; - if (assignable) report(expr, Codes.unknownFlow, `Unknown data cannot flow into ${show(target)} here; decode it first (\`decode T from ...\`).${responseHint}`, decodeFix(expr)); + const response = (target.isUnion() ? target.types : [target]).some((t) => show(t) === "Response"); + const advice = response + ? "`fetch` returns a SeamResponse, whose json() stays Unknown: type it `SeamResponse` instead of `Response`." + : "decode it first (`decode T from ...`)."; + if (!assignable) return true; + const place = placeOf(expr); + report(expr, Codes.unknownFlow, `Unknown data${place.text} cannot flow into ${show(target)} here; ${advice}`, decodeFix(expr), place.origin); return true; }; @@ -841,7 +947,7 @@ export function createChecker(ts: typeof import("typescript"), options: CheckerO // An object spread copies the fields out from under the brand: the copy's // type has only the brand's symbol key, which TypeScript lets pass as // `Record` and the like. It never keeps the data Unknown. - if (hasUnknown(node.expression)) report(node, Codes.unknownFlow, exitMessage(ts.isJsxSpreadAttribute(node) ? "spread into JSX props" : "spread into an object")); + if (hasUnknown(node.expression)) reportExit(node, ts.isJsxSpreadAttribute(node) ? "spread into JSX props" : "spread into an object", node.expression); else checkValue(node.expression); } else if (ts.isJsxExpression(node)) { checkValue(node.expression); @@ -851,12 +957,13 @@ export function createChecker(ts: typeof import("typescript"), options: CheckerO if (narrowedUnknown(node.expression)) { report(node, Codes.unknownFlow, narrowedMessage); } else if (containsUnknown(source) && (!containsUnknown(target) || absorbs(source, target))) { - report(node, Codes.unknownFlow, "Unknown data cannot be asserted with `as`; decode it instead (`decode T from ...`)."); + const place = placeOf(node.expression); + report(node, Codes.unknownFlow, `Unknown data${place.text} cannot be asserted with \`as\`; decode it instead (\`decode T from ...\`).`, undefined, place.origin); } } else if (ts.isTemplateSpan(node)) { - if (hasUnknown(node.expression)) report(node.expression, Codes.unknownFlow, exitMessage("interpolated into a template")); + if (hasUnknown(node.expression)) reportExit(node.expression, "interpolated into a template", node.expression); } else if (ts.isThrowStatement(node)) { - if (hasUnknown(node.expression)) report(node.expression, Codes.unknownFlow, exitMessage("thrown")); + if (hasUnknown(node.expression)) reportExit(node.expression, "thrown", node.expression); } if (options.externalAny !== "allow" && (ts.isPropertyAccessExpression(node) || ts.isCallExpression(node) || (ts.isIdentifier(node) && isBareReference(node)))) { diff --git a/packages/compiler/src/program.ts b/packages/compiler/src/program.ts index 9e90173..4a80217 100644 --- a/packages/compiler/src/program.ts +++ b/packages/compiler/src/program.ts @@ -14,7 +14,7 @@ import { decodedMappings, originalPositionFor, TraceMap } from "@jridgewell/trac // Loaded with require: importing TypeScript's CommonJS API as ESM makes Node // scan all of it for export names first, about 100 ms on every run. import ts = require("typescript"); -import { type CheckerOptions, createChecker, type Finding } from "./checker.js"; +import { type CheckerOptions, createChecker, type Finding, withOriginLine } from "./checker.js"; import type { Diagnostic } from "./diagnostics.js"; import { isSeamFile, RUNTIME_MODULE, type TransformResult, transform, type UnknownWrap } from "./transform.js"; @@ -217,7 +217,12 @@ export function createSeamProgram( function fromFinding(f: Finding, fileName: string, sf: ts.SourceFile, map: TraceMap): Diagnostic { const pos = sf.getLineAndCharacterOfPosition(f.pos); - return { file: fileName, ...originalPosition(map, pos.line, pos.character), code: f.code, message: f.message, category: "error" }; + let originLine: number | undefined; + if (f.origin !== undefined) { + const o = sf.getLineAndCharacterOfPosition(f.origin); + originLine = originalPosition(map, o.line, o.character).line; + } + return { file: fileName, ...originalPosition(map, pos.line, pos.character), code: f.code, message: withOriginLine(f.message, originLine), category: "error" }; } function fromTs(d: ts.Diagnostic, map: TraceMap | undefined): Diagnostic { diff --git a/packages/compiler/src/transform.ts b/packages/compiler/src/transform.ts index cf36e13..7cd5f90 100644 --- a/packages/compiler/src/transform.ts +++ b/packages/compiler/src/transform.ts @@ -38,7 +38,8 @@ export const DEFERRED_CORE_MODULE = "@seamscript/core/deferred"; /** Runtime names a `.seam.ts` file may use without importing them (when it does not bind them itself). */ const AMBIENT_VALUES = ["ChunkStream", "Decimal", "Int64", "Pcm", "Text", "Unknown", "Zoned", "fetch"]; // SeamResponse is what the ambient `fetch` returns, so that a variable for it can be typed. -const AMBIENT_TYPES = ["Bytes", "DecodeError", "Err", "Ok", "Planar", "Result", "SeamResponse", "Stale"]; +// Decoder is the type of a boundary's value, so that a function can take one (`b: Decoder`). +const AMBIENT_TYPES = ["Bytes", "DecodeError", "Decoder", "Err", "Ok", "Planar", "Result", "SeamResponse", "Stale"]; /** * An expression to mark as Unknown, found by the checker's first pass. Offsets diff --git a/packages/compiler/test/checker.test.ts b/packages/compiler/test/checker.test.ts index 27e8cc3..08e38eb 100644 --- a/packages/compiler/test/checker.test.ts +++ b/packages/compiler/test/checker.test.ts @@ -66,9 +66,69 @@ describe("sources", () => { const body = (type: string) => `export async function f() {\n let res: ${type};\n res = await fetch("/x");\n return res;\n}\n`; const [d] = check({ "a.seam.ts": body("Response") }).diagnostics; expect(d?.code).toBe("SEAM2001"); - expect(d?.message).toContain("type the variable `SeamResponse`"); + expect(d?.message).toContain("type it `SeamResponse`"); // SeamResponse needs no import, like fetch itself. expect(codesByLine(body("SeamResponse"))).toEqual([]); + // The usual shape, `let res: Response | undefined` before a try, gets the hint too. + const [u] = check({ "b.seam.ts": body("Response | undefined") }).diagnostics; + expect(u?.message).toBe( + "Unknown data in `fetch(\"/x\").json()` (`fetch(\"/x\")` is SeamResponse) cannot flow into Response | undefined here; `fetch` returns a SeamResponse, whose json() stays Unknown: type it `SeamResponse` instead of `Response`.", + ); + }); + + it("says which value holds the Unknown data and where it came from", () => { + const source = `export async function f(res: SeamResponse) { + const text = await res.text(); + const same = text; + const s: unknown = same; + const t: unknown = await res.json(); + const box = { inner: [text] }; + const u: unknown = box; + return [s, t, u]; +} +`; + expect(check({ "a.seam.ts": source }).diagnostics.map((d) => [d.line, d.message])).toEqual([ + [4, "Unknown data in `same` (from `res.text()`, line 2) cannot flow into unknown here; decode it first (`decode T from ...`)."], + [5, "Unknown data from `res.json()` cannot flow into unknown here; decode it first (`decode T from ...`)."], + [7, "Unknown data in `box.inner[i]` (`box` is { inner: Unknown[]; }) cannot flow into unknown here; decode it first (`decode T from ...`)."], + ]); + }); + + it("lets a function take a boundary as a Decoder, without an import", () => { + const source = `boundary Order { id: string } +async function get(b: Decoder, url: string): Promise> { + const res = await fetch(url); + return decode b from json await res.text(); +} +export const order = get(Order, "/orders/1"); +`; + expect(codesByLine(source)).toEqual([]); + }); + + it("lets Unknown be carried in places typed Unknown, and only decode look inside", () => { + const source = `boundary P { a: string } +type Envelope = { body: Unknown; at: number }; +function open(u: Unknown) { return decode P from u; } +export async function f(res: SeamResponse) { + const v = await res.json(); + const e: Envelope = { body: v, at: 1 }; + const all: Unknown[] = [v, e.body]; + open(e.body); + const peek: unknown = e.body; + return [all, peek]; +} +`; + expect(codesByLine(source)).toEqual([[9, "SEAM2001"]]); + }); + + it("makes test data Unknown with Unknown.of, which decode then checks", () => { + const source = `boundary P { a: string } +export const ok = decode P from Unknown.of({ a: "x" }); +export const carried: Unknown = Unknown.of(1); +export const again = Unknown.of(carried); +const s: string = Unknown.of("x"); +`; + expect(codesByLine(source)).toEqual([[5, "TS2322"]]); }); it("keeps the brands of an object boundary's fields through decode", () => { diff --git a/packages/compiler/test/golden/expected/cases/diagnostics.txt b/packages/compiler/test/golden/expected/cases/diagnostics.txt index 3a7aced..24dbe52 100644 --- a/packages/compiler/test/golden/expected/cases/diagnostics.txt +++ b/packages/compiler/test/golden/expected/cases/diagnostics.txt @@ -22,11 +22,11 @@ packages/compiler/test/golden/cases/errors-declarations.seam.ts(27,23): error SE packages/compiler/test/golden/cases/errors-declarations.seam.ts(30,3): error SEAM1102: A boundary must be declared at the top level of a module; move it out of the function or block (export it if other modules need it). packages/compiler/test/golden/cases/errors-declarations.seam.ts(34,8): error SEAM1401: A latest function cannot be a generator; remove the `*` and return the final value (a latest function settles once per call). packages/compiler/test/golden/cases/errors-declarations.seam.ts(39,51): error SEAM1402: This parameter is an AbortSignal, but its type is not written `AbortSignal`, so it is not recognized: write `AbortSignal` here and the latest function supplies the signal (callers leave it out). -packages/compiler/test/golden/cases/errors-flow.seam.ts(8,19): error SEAM2001: Unknown data cannot be asserted with `as`; decode it instead (`decode T from ...`). +packages/compiler/test/golden/cases/errors-flow.seam.ts(8,19): error SEAM2001: Unknown data in `v` (from `res.json()`, line 7) cannot be asserted with `as`; decode it instead (`decode T from ...`). packages/compiler/test/golden/cases/errors-flow.seam.ts(8,19): error TS2352: Conversion of type 'Unknown' to type 'Order' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'Unknown' is missing the following properties from type 'Order': id, memo, total, placedAt, and 10 more. -packages/compiler/test/golden/cases/errors-flow.seam.ts(9,22): error SEAM2001: Unknown data cannot flow into unknown here; decode it first (`decode T from ...`). -packages/compiler/test/golden/cases/errors-flow.seam.ts(10,19): error SEAM2001: Unknown data cannot be interpolated into a template; decode it first (`decode T from ...`). +packages/compiler/test/golden/cases/errors-flow.seam.ts(9,22): error SEAM2001: Unknown data in `v` (from `res.json()`, line 7) cannot flow into unknown here; decode it first (`decode T from ...`). +packages/compiler/test/golden/cases/errors-flow.seam.ts(10,19): error SEAM2001: Unknown data in `v` (from `res.json()`, line 7) cannot be interpolated into a template; decode it first (`decode T from ...`). packages/compiler/test/golden/cases/errors-flow.seam.ts(11,15): error SEAM2001: Unknown data cannot be concatenated or added; decode it first (`decode T from ...`). packages/compiler/test/golden/cases/errors-flow.seam.ts(11,15): error TS2365: Operator '+' cannot be applied to types 'Unknown' and 'number'. packages/compiler/test/golden/cases/errors-flow.seam.ts(12,15): error SEAM2001: Unknown data cannot be tested with `in`; decode it first (`decode T from ...`). @@ -38,5 +38,5 @@ packages/compiler/test/golden/cases/errors-flow.seam.ts(17,44): error TS2339: Pr packages/compiler/test/golden/cases/errors-flow.seam.ts(19,13): error SEAM2101: .length works on UTF-16 code units; use Text.length(t) for graphemes. packages/compiler/test/golden/cases/errors-flow.seam.ts(20,17): error SEAM2101: Indexing Text reads UTF-16 code units; use Text.at(t, i) for graphemes. packages/compiler/test/golden/cases/errors-flow.seam.ts(21,31): error SEAM2201: JSON.stringify cannot serialize bigint (Int64 is a bigint); pass the boundary's encoded form, e.g. `Order.encode(order)`. -packages/compiler/test/golden/cases/errors-flow.seam.ts(22,20): error SEAM2001: Unknown data cannot be thrown; decode it first (`decode T from ...`). +packages/compiler/test/golden/cases/errors-flow.seam.ts(22,20): error SEAM2001: Unknown data in `v` (from `res.json()`, line 7) cannot be thrown; decode it first (`decode T from ...`). packages/compiler/test/golden/cases/errors-syntax.seam.ts(5,1): error SEAM1000: Unexpected token diff --git a/packages/compiler/test/golden/expected/demo/diagnostics.txt b/packages/compiler/test/golden/expected/demo/diagnostics.txt index 25ddf82..c7da962 100644 --- a/packages/compiler/test/golden/expected/demo/diagnostics.txt +++ b/packages/compiler/test/golden/expected/demo/diagnostics.txt @@ -1 +1 @@ -demo/seamscript/src/load-order.seam.ts(9,22): error SEAM2001: Unknown data cannot flow into unknown here; decode it first (`decode T from ...`). +demo/seamscript/src/load-order.seam.ts(9,22): error SEAM2001: Unknown data in `v` (from `res.json()`, line 8) cannot flow into unknown here; decode it first (`decode T from ...`). diff --git a/packages/runtime/README.md b/packages/runtime/README.md index fa01474..2339990 100644 --- a/packages/runtime/README.md +++ b/packages/runtime/README.md @@ -124,4 +124,4 @@ const status = poll((signal) => readStatus(signal), { every: 5 * 60_000, onResul ## Unknown and fetch -`Unknown` is the type of data from outside, and its only exits are `decode` and `Unknown.log(v)` (for debugging; it only prints the value). Which values are outside data is decided by the compiler: the web APIs that deliver it (`Body.json`, `text`, `arrayBuffer` and `bytes`, `Blob.arrayBuffer` and `bytes`, `MediaStreamTrack.getSettings`, an AudioWorklet's `process` inputs, `JSON.parse`, `Storage.getItem`, `URLSearchParams.get`, `MessageEvent.data`, `IDBRequest.result`, `Clipboard.readText`, `Blob.text`, `FileReader.result`, `Location.hash`, `History.state`, `Document.cookie`, and others), plus whatever the project declares in `tsconfig.json` (see `@seamscript/compiler`). Inside `.seam.ts`, `fetch` comes from this package: underneath it is the global `fetch`, but `res.json()` has the type `Promise`. +`Unknown` is the type of data from outside, and its only exits are `decode` and `Unknown.log(v)` (for debugging; it only prints the value). `Unknown.of(v)` goes the other way: it marks a value as outside data, for tests, and returns it unchanged. Which values are outside data is decided by the compiler: the web APIs that deliver it (`Body.json`, `text`, `arrayBuffer` and `bytes`, `Blob.arrayBuffer` and `bytes`, `MediaStreamTrack.getSettings`, an AudioWorklet's `process` inputs, `JSON.parse`, `Storage.getItem`, `URLSearchParams.get`, `MessageEvent.data`, `IDBRequest.result`, `Clipboard.readText`, `Blob.text`, `FileReader.result`, `Location.hash`, `History.state`, `Document.cookie`, and others), plus whatever the project declares in `tsconfig.json` (see `@seamscript/compiler`). Inside `.seam.ts`, `fetch` comes from this package: underneath it is the global `fetch`, but `res.json()` has the type `Promise`. diff --git a/packages/runtime/src/unknown.ts b/packages/runtime/src/unknown.ts index d82ae85..88e30c7 100644 --- a/packages/runtime/src/unknown.ts +++ b/packages/runtime/src/unknown.ts @@ -8,6 +8,14 @@ import type { Brand } from "./brand.js"; export type Unknown = Brand<"Unknown">; export const Unknown = { + /** + * Marks a value as outside data, for tests: `decode Order from Unknown.of({ id: "1" })` + * checks it exactly as it would a response body. It changes nothing at run time. + * Marking a value Unknown only takes uses away, so it is allowed anywhere. + */ + of(value: T): Unknown { + return value as unknown as Unknown; + }, /** Debug-only exit: prints the value (the contents, for a boxed Unknown) and returns nothing. */ log(value: T): void { console.log(__unbox(value)); diff --git a/packages/runtime/test/decoder.test.ts b/packages/runtime/test/decoder.test.ts index 8f0b3cb..c8de73f 100644 --- a/packages/runtime/test/decoder.test.ts +++ b/packages/runtime/test/decoder.test.ts @@ -10,6 +10,7 @@ import { MAX_DEPTH, type ObjectDecoder, type Text, + Unknown, type Zoned, } from "../src/index.js"; @@ -401,3 +402,14 @@ describe("constraints", () => { expect(Account.encode(value)).toEqual({ ...good, quota: "5" }); }); }); + +describe("Unknown.of", () => { + it("leaves the value as it is, for decode to check like outside data", () => { + const value = { a: "x" }; + const u = Unknown.of(value); + expect(u).toBe(value); + const P = __b.object<{ a: string }>({ a: __b.string }); + expect(__decode(P, u)).toEqual({ ok: true, value: { a: "x" } }); + expect(__decode(P, Unknown.of({ a: 1 })).ok).toBe(false); + }); +}); diff --git a/packages/ts-plugin/src/index.ts b/packages/ts-plugin/src/index.ts index 5d3fe74..506c34e 100644 --- a/packages/ts-plugin/src/index.ts +++ b/packages/ts-plugin/src/index.ts @@ -12,7 +12,7 @@ // with the wraps the code was made with, and when they differ the code is made // again and the check repeated. The wrapped program finds the same sites, so this // settles after one round. -import { createChecker, type Finding } from "@seamscript/compiler/checker"; +import { createChecker, type Finding, withOriginLine } from "@seamscript/compiler/checker"; import { readSeamConfig } from "@seamscript/compiler/config"; import { isSeamFile, RUNTIME_MODULE, type UnknownWrap } from "@seamscript/compiler/transform"; import type { Language, LanguagePlugin } from "@volar/language-core"; @@ -106,7 +106,13 @@ const plugin = createLanguageServicePlugin((tsModule, info) => { const fromFinding = (code: SeamCode, file: ts.SourceFile | undefined, f: Finding) => { const start = toSource(code, f.pos); const end = toSource(code, Math.max(f.pos, f.end - 1)) + 1; - const d = diagnostic(file, start, end - start, f.code, f.message); + let originLine: number | undefined; + if (f.origin !== undefined) { + const at = toSource(code, f.origin); + originLine = 1; + for (let i = code.source.indexOf("\n"); i >= 0 && i < at; i = code.source.indexOf("\n", i + 1)) originLine++; + } + const d = diagnostic(file, start, end - start, f.code, withOriginLine(f.message, originLine)); if (f.fix !== undefined) { // Every edit must land in text kept from the source, or the fix is not offered. const changes = f.fix.edits.map((e) => { @@ -164,7 +170,7 @@ const plugin = createLanguageServicePlugin((tsModule, info) => { : [{ file, start: 0, length: 0, messageText: mismatch, category: tsModule.DiagnosticCategory.Warning, code: 9001 /* SEAM9001 */, source: "seamscript" }]), ...fromTransform(code, file, false), ...[...findings, ...checker.checkFlows(program, file, runtimeOf(fileName))].flatMap((f) => { - const shifted = { ...f, pos: f.pos - lead, end: f.end - lead, ...(f.fix ? { fix: { ...f.fix, edits: f.fix.edits.map((e) => ({ ...e, pos: e.pos - lead, end: e.end - lead })) } } : {}) }; + const shifted = { ...f, pos: f.pos - lead, end: f.end - lead, ...(f.origin !== undefined ? { origin: f.origin - lead } : {}), ...(f.fix ? { fix: { ...f.fix, edits: f.fix.edits.map((e) => ({ ...e, pos: e.pos - lead, end: e.end - lead })) } } : {}) }; const d = fromFinding(code, file, shifted); return f.fixOnly ? [] : [d]; }), diff --git a/packages/ts-plugin/test/plugin.test.ts b/packages/ts-plugin/test/plugin.test.ts index fb91a26..b30e32b 100644 --- a/packages/ts-plugin/test/plugin.test.ts +++ b/packages/ts-plugin/test/plugin.test.ts @@ -58,6 +58,10 @@ describe("a project of .seam.ts files", () => { it("reports TypeScript's errors and SeamScript's checks where they are", async () => { // JSON.parse is outside data: Unknown, so it cannot be asserted or assigned to string. expect(codes(await semantic(use)).sort()).toEqual(["SEAM2001@7", "TS2322@8", "TS2352@7"]); + // The message names where the Unknown came from, with its line in the source. + expect((await semantic(use)).find((d) => d.source === "seamscript")?.text).toBe( + 'Unknown data in `raw` (from `JSON.parse("{}")`, line 6) cannot be asserted with `as`; decode it instead (`decode T from ...`).', + ); expect(await semantic(api)).toEqual([]); expect(await syntactic(api)).toEqual([]); }); From ce35253099698dbf5be4f958f0d5775e9c4ff282 Mon Sep 17 00:00:00 2001 From: Shogo256 Date: Sun, 15 Nov 2026 18:06:13 +0900 Subject: [PATCH 2/3] Release 0.1.3 --- CHANGELOG.md | 2 +- DECISIONS.md | 2 +- demo/seamscript/package.json | 4 ++-- packages/compiler/package.json | 6 +++--- packages/core/package.json | 6 +++--- packages/create-seamscript/package.json | 2 +- packages/parser/package.json | 2 +- packages/react/package.json | 6 +++--- packages/runtime/package.json | 2 +- packages/ts-plugin/package.json | 4 ++-- packages/vscode/package.json | 2 +- sandbox/app/package.json | 8 ++++---- sandbox/backend/package.json | 4 ++-- sandbox/bench/package.json | 6 +++--- sandbox/voice/package.json | 4 ++-- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0512dd7..d6903bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All `@seamscript/*` packages and `create-seamscript` are released together, with one version number. Releases are on GitHub: https://github.com/Shogo256/SeamScript/releases -## Unreleased +## 0.1.3 ### Added diff --git a/DECISIONS.md b/DECISIONS.md index d8c5788..84f6e2d 100644 --- a/DECISIONS.md +++ b/DECISIONS.md @@ -366,7 +366,7 @@ Found by the first production app (CS Pro's chat widget), which asks a server th - **SEAM1403 checks only what it can see.** A `fetch` in a latest function's body (including nested callbacks) with no init, or with an object-literal init without `signal`, is reported. An init in a variable, or a literal with a spread, is not: the checker can't tell what is in it, and a false error would teach people to silence the check. Any `signal` property counts (`AbortSignal.any([signal, ...])` is legitimate). - **`poll` is a runtime function, not language.** Polling has no data that needs the compiler: the reads are ordinary (decode, Result). It runs one read at a time instead of on a fixed timer, so a slow server is never hit by overlapping reads; backs off only on failure; and pauses while the page is hidden, because a background tab polling every few minutes, in every tab a user keeps open, is load nobody sees. Long polling, SSE and debounce stay out: no app here needs them yet. -## Passing boundaries and outside data around (after 0.1.2) +## Passing boundaries and outside data around (0.1.3) Raised by a user's list of language proposals. Of the five, two already worked and only needed to be shown (a boundary as a `Decoder` argument; Unknown in fields, arrays and parameters typed Unknown), one was already the design (`SeamResponse` passes freely; only the lib's `Response` is refused), and two were new: diff --git a/demo/seamscript/package.json b/demo/seamscript/package.json index 6d5a425..9ee2979 100644 --- a/demo/seamscript/package.json +++ b/demo/seamscript/package.json @@ -8,10 +8,10 @@ "test": "vitest run" }, "dependencies": { - "@seamscript/runtime": "0.1.2" + "@seamscript/runtime": "0.1.3" }, "devDependencies": { - "@seamscript/compiler": "0.1.2", + "@seamscript/compiler": "0.1.3", "typescript": "5.9.3", "vite": "8.3.4", "vitest": "5.0.3" diff --git a/packages/compiler/package.json b/packages/compiler/package.json index c49fece..b10a4b3 100644 --- a/packages/compiler/package.json +++ b/packages/compiler/package.json @@ -1,6 +1,6 @@ { "name": "@seamscript/compiler", - "version": "0.1.2", + "version": "0.1.3", "description": "SeamScript compiler: expands .seam.ts into plain TypeScript and checks boundaries", "keywords": [ "seamscript", @@ -69,13 +69,13 @@ "dependencies": { "@babel/types": "8.0.6", "@jridgewell/trace-mapping": "0.3.31", - "@seamscript/parser": "0.1.2", + "@seamscript/parser": "0.1.3", "magic-string": "1.4.3", "typescript": "5.9.3", "unplugin": "3.4.0" }, "devDependencies": { - "@seamscript/runtime": "0.1.2", + "@seamscript/runtime": "0.1.3", "@types/node": "24.19.2", "rollup": "4.64.6", "vite": "8.3.4", diff --git a/packages/core/package.json b/packages/core/package.json index 9b6444e..45fd629 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@seamscript/core", - "version": "0.1.2", + "version": "0.1.3", "description": "WASM core for SeamScript's Text: grapheme segmentation and normalization at a pinned Unicode version", "keywords": [ "seamscript", @@ -43,7 +43,7 @@ "access": "public" }, "devDependencies": { - "@seamscript/runtime": "0.1.2", + "@seamscript/runtime": "0.1.3", "@types/node": "24.19.2", "fast-check": "4.10.2", "typescript": "5.9.3", @@ -51,7 +51,7 @@ "vitest": "5.0.3" }, "peerDependencies": { - "@seamscript/runtime": "0.1.2" + "@seamscript/runtime": "0.1.3" }, "engines": { "node": ">=20" diff --git a/packages/create-seamscript/package.json b/packages/create-seamscript/package.json index 0796531..8d35cf0 100644 --- a/packages/create-seamscript/package.json +++ b/packages/create-seamscript/package.json @@ -1,6 +1,6 @@ { "name": "create-seamscript", - "version": "0.1.2", + "version": "0.1.3", "description": "Start a SeamScript app: `npm create seamscript my-app` sets up Vite, seamc check, the WASM core and editor support", "keywords": [ "seamscript", diff --git a/packages/parser/package.json b/packages/parser/package.json index 9adb689..3d2930e 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@seamscript/parser", - "version": "0.1.2", + "version": "0.1.3", "description": "Fork of @babel/parser 8.0.7 that adds SeamScript syntax: boundary, decode … from, latest", "keywords": [ "seamscript", diff --git a/packages/react/package.json b/packages/react/package.json index 3d23d5b..b29703d 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@seamscript/react", - "version": "0.1.2", + "version": "0.1.3", "description": "React bindings for SeamScript: useFork gives a component its own line of a latest function, cancelled on unmount", "keywords": [ "seamscript", @@ -36,11 +36,11 @@ "access": "public" }, "peerDependencies": { - "@seamscript/runtime": "0.1.2", + "@seamscript/runtime": "0.1.3", "react": ">=18" }, "devDependencies": { - "@seamscript/runtime": "0.1.2", + "@seamscript/runtime": "0.1.3", "@types/react": "19.3.0", "@types/react-dom": "19.3.0", "happy-dom": "20.14.5", diff --git a/packages/runtime/package.json b/packages/runtime/package.json index b57c883..b3a6dd0 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@seamscript/runtime", - "version": "0.1.2", + "version": "0.1.3", "description": "Runtime library for SeamScript: boundary decoders, latest, Text / Int64 / Decimal / Zoned", "keywords": [ "seamscript", diff --git a/packages/ts-plugin/package.json b/packages/ts-plugin/package.json index 85d0b18..ab2a2a7 100644 --- a/packages/ts-plugin/package.json +++ b/packages/ts-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@seamscript/ts-plugin", - "version": "0.1.2", + "version": "0.1.3", "description": "TypeScript language service plugin for SeamScript: completions, hover, navigation, rename and SeamScript's diagnostics for .seam.ts files in any editor that runs tsserver", "keywords": [ "seamscript", @@ -30,7 +30,7 @@ "access": "public" }, "devDependencies": { - "@seamscript/compiler": "0.1.2", + "@seamscript/compiler": "0.1.3", "@types/node": "24.19.2", "@volar/language-core": "2.4.28", "@volar/typescript": "2.4.28", diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 2dea50a..eb9104e 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -41,7 +41,7 @@ "test": "vitest run" }, "devDependencies": { - "@seamscript/ts-plugin": "0.1.2", + "@seamscript/ts-plugin": "0.1.3", "@vscode/vsce": "4.0.0", "tm-grammars": "1.32.22", "vitest": "5.0.3", diff --git a/sandbox/app/package.json b/sandbox/app/package.json index 504fa58..655f80f 100644 --- a/sandbox/app/package.json +++ b/sandbox/app/package.json @@ -10,14 +10,14 @@ "check": "seamc check -p tsconfig.json" }, "dependencies": { - "@seamscript/core": "0.1.2", - "@seamscript/react": "0.1.2", - "@seamscript/runtime": "0.1.2", + "@seamscript/core": "0.1.3", + "@seamscript/react": "0.1.3", + "@seamscript/runtime": "0.1.3", "react": "19.3.0", "react-dom": "19.3.0" }, "devDependencies": { - "@seamscript/compiler": "0.1.2", + "@seamscript/compiler": "0.1.3", "@types/react": "19.3.0", "@types/react-dom": "19.3.0", "@vitejs/plugin-react": "6.1.2", diff --git a/sandbox/backend/package.json b/sandbox/backend/package.json index 7c38fd3..28085a4 100644 --- a/sandbox/backend/package.json +++ b/sandbox/backend/package.json @@ -13,8 +13,8 @@ "test": "tsc -p tsconfig.json && node --test test/*.test.ts" }, "dependencies": { - "@seamscript/core": "0.1.2", - "@seamscript/runtime": "0.1.2", + "@seamscript/core": "0.1.3", + "@seamscript/runtime": "0.1.3", "ws": "8.22.0" }, "devDependencies": { diff --git a/sandbox/bench/package.json b/sandbox/bench/package.json index 47fae43..3a95dab 100644 --- a/sandbox/bench/package.json +++ b/sandbox/bench/package.json @@ -9,13 +9,13 @@ "budgets": "node scripts/check-budgets.ts" }, "dependencies": { - "@seamscript/core": "0.1.2", - "@seamscript/runtime": "0.1.2", + "@seamscript/core": "0.1.3", + "@seamscript/runtime": "0.1.3", "zod": "4.6.6" }, "devDependencies": { "@playwright/test": "1.61.1", - "@seamscript/compiler": "0.1.2", + "@seamscript/compiler": "0.1.3", "@types/node": "24.19.2", "typescript": "5.9.3", "vite": "8.3.4" diff --git a/sandbox/voice/package.json b/sandbox/voice/package.json index 70aa6f2..68dfa52 100644 --- a/sandbox/voice/package.json +++ b/sandbox/voice/package.json @@ -10,10 +10,10 @@ "check": "seamc check -p tsconfig.json" }, "dependencies": { - "@seamscript/runtime": "0.1.2" + "@seamscript/runtime": "0.1.3" }, "devDependencies": { - "@seamscript/compiler": "0.1.2", + "@seamscript/compiler": "0.1.3", "typescript": "5.9.3", "vite": "8.3.4" } From 52b144e1a7739687f51a7e522234185393f23b1d Mon Sep 17 00:00:00 2001 From: Shogo256 Date: Sun, 15 Nov 2026 18:16:49 +0900 Subject: [PATCH 3/3] Retry a page navigation that gets no page within 20 s in the E2E tests In CI, WebKit once left the HTML request of the deep-nesting test without a response for the whole 60 s, right after the same backend had answered an admin call. The test's subject starts once the page is there, so App.navigate tries the navigation a second time and records it as an annotation; App.open and the deep-nesting test use it. --- sandbox/e2e/support/fixtures.ts | 19 ++++++++++++++++++- sandbox/e2e/tests/scale.spec.ts | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/sandbox/e2e/support/fixtures.ts b/sandbox/e2e/support/fixtures.ts index 61a7e0a..d2e11c6 100644 --- a/sandbox/e2e/support/fixtures.ts +++ b/sandbox/e2e/support/fixtures.ts @@ -65,10 +65,27 @@ export class App { } async open(path = "/"): Promise { - await this.page.goto(path); + await this.navigate(path); await this.live(); } + /** + * Loads a page, trying a second time if the first navigation gets no page within + * 20 s. In CI, WebKit has once left the very first request of a page (the HTML, + * served by the same backend that had just answered an admin call) without a + * response for the whole test. That is the browser or the runner, not the app: + * what a test checks starts once the page is there. + */ + async navigate(path = "/"): Promise { + try { + await this.page.goto(path, { timeout: 20_000 }); + } catch (e) { + if (!(e instanceof Error) || e.name !== "TimeoutError") throw e; + base.info().annotations.push({ type: "navigation retried", description: `${path}: ${e.message.split("\n")[0]}` }); + await this.page.goto(path, { timeout: 20_000 }); + } + } + async live(timeout = 15_000): Promise { await expect(this.page.getByTestId("status")).toHaveAttribute("data-status", "live", { timeout }); } diff --git a/sandbox/e2e/tests/scale.spec.ts b/sandbox/e2e/tests/scale.spec.ts index 2397a2d..1cee9b9 100644 --- a/sandbox/e2e/tests/scale.spec.ts +++ b/sandbox/e2e/tests/scale.spec.ts @@ -24,7 +24,7 @@ test.describe("Large data", () => { test("100,000 levels of nesting in an HTTP response: reported without crashing, caught up once fixed", async ({ app, backend, page }, testInfo) => { await backend.faults({ http: { deepNesting: 100_000 } }); - await page.goto("/"); + await app.navigate("/"); // Either the browser's JSON parser copes (the field is ignored by decode) or it // throws, which the app reports as a problem and retries. Both are fine; a crash is not. await expect