test: delete the unreachable seal() hook and guard non-object RPC bodies
All checks were successful
check / check (push) Successful in 24s

Three review findings, no redesign.

seal() was installed after session.close(), so onLate could never fire:
once the context is destroyed no route handler and no console listener
exists to record anything. It was dead code that the attribution table,
run.js and harness.js all described as the final safety net. Deleted
rather than moved — take() already drains everything the collector holds
before teardown, so it covered nothing, and this harness must not ship a
mechanism it cannot demonstrate. The now-unreachable `late > 0` term in
the failure condition goes with it.

handleRpc() parsed `postData || "null"` and then dereferenced the result,
so a POST whose body Playwright reports as null — a bodyless request, or
any payload it cannot decode as UTF-8, e.g. sendBeacon with a Blob —
threw a TypeError inside the route handler and killed node mid-suite:
truncated TAP, no summary, no failure line. Non-object payloads now take
the same path as unparseable ones and are reported as unstubbed traffic,
which is the entire point of that branch.

README claimed unrecognised outbound requests are reported as failures,
unqualified, while observation in fact ends TRAILING_WATCH_MS after the
last test returns. The limit is now stated where it lands.
This commit is contained in:
clawbot
2026-08-09 16:26:26 +00:00
parent a13862d991
commit 82c40e009d
4 changed files with 42 additions and 31 deletions

View File

@@ -167,7 +167,13 @@ async function main() {
// nowhere)
// end of test k .. end of k+1 -> test k+1
// last test .. teardown -> the suite, via the trailing drain
// after the trailing drain -> seal(), which fails on the spot
//
// Those three phases cover the entire life of the browser context.
// There is no fourth: once the context is closed nothing can record,
// because the route handler and the console listeners died with it.
// Traffic that a test defers past the trailing drain is therefore
// never observed at all — a real limit of this design, stated in the
// README, and not one any post-teardown hook could close.
//
// Two green-but-vacuous runs on this harness were the same shape: a
// record falling outside somebody's window and being dropped. First
@@ -230,17 +236,6 @@ async function main() {
// reported, and they fail the run.
const trailing = session.errors.take();
// From here the run is over and there is nothing left to attribute a
// record to, so stragglers fail immediately instead of piling up
// where nothing will read them.
let late = 0;
session.errors.seal((line) => {
late += 1;
console.log("# FAILED: browser error recorded after the run ended");
console.log("# " + line);
process.exitCode = 1;
});
console.log(
"# " + (tests.length - failed) + "/" + tests.length + " tests passed",
);
@@ -257,7 +252,7 @@ async function main() {
}
}
if (failed > 0 || trailing.length > 0 || late > 0) {
if (failed > 0 || trailing.length > 0) {
console.log("# FAILED");
process.exitCode = 1;
}