Repository navigation
fix(page): stop parsing a streaming document after Page.stopLoading - #2817
Conversation
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review of e50fc1e
No blocking findings
Checked against origin/main f98df6c. The PR is a single commit on main and does not include #2800's commits.
- Correctness:
streaming_residence.rs:94-103. When a parked main-document continuation resumes afterPage.stopLoading, chunks that arrived after the stop are not enqueued. The input is closed once:input_finished = true, so the continuation is never re-parked asopen_streaming, and the deferred-failure branch is excluded. The prefix that was already parsed stays in the DOM.readyStatestayscompleteand no load event fires, because the existingstop_loading_without_load_eventalready setsload = Suppressedand clears the interactive/DCL/complete tokens. Chrome behaves the same here:stop-streamon headless Chrome givescomplete | <p id="prefix">committed prefix</p>after 8 s, with noPage.loadEventFired. Stopping when no streaming continuation exists is a no-op. The flag is not sticky. It comes from the current document's lifecycle snapshot, and a cross-document commit installs a new lifecycle viastart_cross_document(page_vm/mod.rs:1483), so the next navigation parses normally. Child-frame documents do not use this continuation. - Cost: one lifecycle-snapshot read per resume of a parked streaming parser. Documents that were not stopped take the existing path. The before/after numbers are plausible.
- Test:
stop_loading_stops_parsing_a_streaming_documentreleases the tail after the stop. Without the change the tail would be parsed, so the test fails as intended. - CI: Clippy, Format, Node, Python and Windows pass. Nextest, CDP smoke and the release builds are still pending.
- Picture: pending.
Non-blocking notes, outside this PR's scope:
- Only input that arrives after the stop is discarded. Bytes that were buffered before the stop but not yet tokenized are still parsed when the parser resumes. For example, the stream contains
<script src=slow.js></script><p>x</p>and the stop happens whileslow.jsis loading. That case belongs with the disclosed subresource-cancellation follow-up for #2765. - The body says that dropping
input"cancels the rest of the body". That happens only at the next wake (the next chunk or EOF). If the server sends nothing more, the connection stays open until then.
CI Regression ReportSource CI run · source state at render:
Release regression — ✅ HEAD/base failures 0/0; raw binary 0.00%Package and image size
Startup latency and PSS
Concurrency matrix
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues; 1 Chromium reference recoveries
Recovered Chromium reference infrastructure failures
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
CDP smoke — ✅ 116/116 groups passed; 1,714 scenariosWorkers: 4 · cumulative group time: 463.87 s · failed groups: 0
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Frozen HTML · Linux · Diagnostics: All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable. |
Spider Bench A/B✅ All benchmark browser service runs completed; results are informational. Public HEAD: 189 / 240 rows; 39 / 48 sites produced rows; 9 unexpected empty sites. ✅ Deterministic fixture contract is clean. Common ancestor Public 48-site run · informational
Public-site content, timing, and memory are noisy. This single A/B run reports evidence only; site outcome counts explain missing rows without treating them as a deterministic regression. CPU and memory timelinesThese are bounded 40-point views of the same complete process-tree samples used by the HTML report. CPU uses 100% per occupied logical core; memory lines are RSS first and PSS second when complete PSS samples are available. Basexychart-beta
title "Base CPU"
x-axis "Elapsed seconds" [1.539, 3.041, 4.545, 6.047, 7.549, 9.05, 10.554, 12.055, 13.557, 15.058, 16.56, 18.063, 19.565, 20.567, 21.068, 22.57, 24.073, 25.574, 26.575, 27.577, 29.079, 30.581, 32.084, 33.586, 35.087, 36.591, 38.092, 39.594, 41.095, 42.597, 44.099, 45.6, 47.101, 48.603, 49.605, 50.105, 51.608, 53.108]
y-axis "CPU percent" 0 --> 200
line [5.99, 99.85, 91.82, 129.86, 109.95, 131.94, 107.73, 127.88, 13.97, 72, 2, 7.98, 2, 0, 3.99, 46, 93.93, 131.93, 103.84, 113.8, 135.96, 137.76, 113.65, 77.89, 5.99, 9.97, 0, 7.99, 0, 5.99, 2, 115.89, 7.99, 11.99, 163.87, 119.9, 131.79, 119.97]
xychart-beta
title "Base memory: RSS then PSS"
x-axis "Elapsed seconds" [0.037, 1.539, 3.041, 4.545, 6.047, 7.549, 9.05, 10.554, 12.055, 13.557, 15.058, 16.56, 18.063, 19.565, 20.567, 21.068, 22.57, 24.073, 25.574, 26.575, 27.577, 29.079, 30.581, 32.084, 33.586, 35.087, 36.591, 38.092, 39.594, 41.095, 42.597, 44.099, 45.6, 47.101, 48.603, 49.605, 50.105, 51.608, 53.108, 54.367]
y-axis "Memory MiB" 0 --> 500
line [13.69, 67.32, 123.72, 118.82, 155.16, 139.72, 150.21, 142.67, 140.25, 122, 129.63, 147.64, 120.21, 123.74, 122.26, 121.33, 126.95, 131.14, 147.91, 269.19, 180.43, 158.14, 163.26, 158.36, 146.82, 132.85, 141.21, 140.22, 140.21, 140.06, 140.04, 140.04, 137.3, 144.75, 128.35, 135.43, 153.77, 160.79, 154.46, 0]
line [10.3, 63.88, 120.28, 115.28, 151.86, 136.14, 146.57, 139.05, 136.63, 118.39, 126.05, 144.02, 116.59, 120.12, 118.64, 117.71, 124.05, 127.87, 144.5, 266.41, 176.85, 154.57, 159.78, 154.74, 143.12, 129.12, 137.58, 136.58, 136.58, 136.43, 136.41, 136.41, 133.67, 141.11, 124.72, 131.93, 151.18, 157.17, 150.86, 0]
HEADxychart-beta
title "HEAD CPU"
x-axis "Elapsed seconds" [1.539, 2.541, 3.041, 4.043, 4.544, 5.545, 7.048, 8.55, 10.052, 11.554, 13.055, 14.557, 15.058, 15.559, 17.061, 18.564, 20.065, 21.567, 23.069, 24.57, 26.073, 27.075, 28.575, 30.077, 31.579, 33.079, 34.58, 36.082, 37.084, 38.586, 40.087, 41.587, 43.09, 44.593, 46.095, 47.097, 48.598, 50.1]
y-axis "CPU percent" 0 --> 200
line [83.92, 111.74, 45.98, 99.81, 131.61, 123.88, 113.76, 91.83, 41.96, 141.94, 2, 4, 0, 37.9, 71.81, 61.84, 39.98, 65.95, 129.86, 107.94, 119.74, 123.86, 105.88, 105.84, 79.89, 27.98, 8, 0, 0, 7.99, 0, 7.99, 119.71, 95.86, 11.99, 105.84, 157.78, 117.91]
xychart-beta
title "HEAD memory: RSS then PSS"
x-axis "Elapsed seconds" [0.037, 1.539, 2.541, 3.041, 4.043, 4.544, 5.545, 7.048, 8.55, 10.052, 11.554, 13.055, 14.557, 15.058, 15.559, 17.061, 18.564, 20.065, 21.567, 23.069, 24.57, 26.073, 27.075, 28.575, 30.077, 31.579, 33.079, 34.58, 36.082, 37.084, 38.586, 40.087, 41.587, 43.09, 44.593, 46.095, 47.097, 48.598, 50.1, 51.426]
y-axis "Memory MiB" 0 --> 500
line [13.73, 92.29, 112.54, 110.37, 127.62, 130.72, 145.77, 144, 125.02, 151.87, 134.85, 124.5, 124.32, 124.29, 132.15, 151.98, 128.82, 132.96, 155.57, 146.57, 250.46, 192.15, 139.52, 172.1, 161.09, 149.71, 139.44, 141.89, 140.79, 140.77, 140.45, 140.41, 140.4, 183.13, 157.41, 130.16, 149.76, 139.74, 157.25, 0]
line [10.28, 88.65, 109.16, 106.75, 123.98, 127.22, 142.54, 140.4, 121.39, 148.24, 131.42, 120.85, 120.68, 120.64, 128.51, 148.33, 124.81, 129.32, 152, 142.92, 246.32, 188.85, 135.87, 168.49, 157.56, 146.13, 135.79, 138.25, 137.14, 137.13, 136.8, 136.77, 136.76, 178.21, 153.77, 126.5, 146.17, 136.17, 153.93, 0]
Deterministic fixture · required contractThe fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.
Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full The public-web A/B is informational. The exact HEAD fixture contract runs as a separate required CI check; timing and public-site content deltas remain non-blocking. |
Sequential Navigation Soak A/B✅ HEAD completed the 200-navigation resilience and memory observation. One browser process, one target, and one CDP session navigate CSDN → SegmentFault → Huaban → example.com repeatedly. This run issued 200 Common ancestor Session resilience
A public-page failure is reported separately from an unrecoverable session. The soak requires all navigation attempts, zero failed recovery, zero lifecycle/network ordering violations, and complete resource evidence. Process-tree memory
HEAD memory by 50-navigation quarter
Raw reports and per-navigation boundary samples: workflow run and full Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold. |
722cea3 to
31d0de3
Compare

**Track:** Trajectory Replay (Browser Eval). Replaces part of #759.Part of #2765.
Replaces part of #759.
Problem
Page.stopLoadingon a document that is still streaming setreadyStatetocompletebut left the streaming parser input open, so bytes that arrived later were still parsed and the DOM kept changing after the stop. Repro (issue case 2):/streamsends<html><body><p id=prefix>committed prefix</p>, waits 8 s, then<p id=tail>tail</p></body></html>; navigate, wait 2 s,Page.stopLoading, readdocument.body.innerHTMLimmediately and after 8 s.Reproduce (steps from #2765, case 2)
/streamsends<html><body><p id=prefix>committed prefix</p>as a chunk, waits 8 s, then sends<p id=tail>tail</p></body></html>.Navigate, wait 2 s, send
Page.stopLoading, and evaluatedocument.body.innerHTMLimmediately and again after 8 s.Expected (Chromium): both reads give
<p id="prefix">committed prefix</p>, andframeStoppedLoadingfires.Actual: immediately after the stop the body is the prefix, but 8 s later it is
<p id="prefix">committed prefix</p><p id="tail">tail</p>. NoframeStoppedLoadingis sent.Change
moli-renderer-v8/src/runtime/page_vm/mod.rs:PageVm::document_loading_was_stopped()reports whether the current document's lifecycle was terminated byPage.stopLoading(the existingStoppedtermination recorded bystop_document_lifecycle).moli-renderer-v8/src/runtime/phase_one/streaming_residence.rs(PendingStreamingPhaseOneContinuation::resume): when the document was stopped, input that arrives afterwards is not parsed; the parser input is closed and the input source is dropped with the continuation, which cancels the rest of the body.stop_loading_stops_parsing_a_streaming_document(protocol-server CDP test): stream a prefix, stop, release the tail; the tail is never parsed andreadyStatestayscomplete.Not covered here: after stopping a committed streaming document moli still sends no
Page.frameStoppedLoading(case 2's second expectation), and subresource fetches are not cancelled on stop. Case 1 (provisional navigation) is #2800.Verification
Before: debug build of
origin/mainf935014; after: debug build of this branch.cargo fmt --all: clean.cargo clippy -p moli-renderer-v8 -p moli-protocol-server --all-targets --all-features -- -D warnings: passed.cargo nextest run -p moli-protocol-server -E 'test(stop_loading)': passed (new test). Negative control: with thestreaming_residence.rschange reverted, the new test fails (tailparsed).cargo nextest run -p moli-renderer-v8 -E 'test(stream) | test(stop) | test(lifecycle)': 1296 passed.Cost
Debug builds,
/usr/bin/time -l, median of 5 runs (repro: two interleaved rounds; shared host):moli serve; ~10.5 s of fixed sleeps)moli fetchof a local 46 KB articleThe new check is one lifecycle-snapshot read when a parked streaming parser resumes; documents that are not stopped take the existing path unchanged, and nothing new is retained.