Repository navigation
computer: Fix result sizes, dispose reasons and late calls in codemode modules - #302
Merged
Merged
Conversation
|
commit: |
ben-reitz
force-pushed
the
browser/codemode-module-fixes
branch
from
November 4, 2026 10:01
fa2bc27 to
f7ef356
Compare
ben-reitz
force-pushed
the
browser/codemode-module-fixes
branch
from
November 4, 2026 10:49
f7ef356 to
0a30691
Compare
In a replayable run, every codemode result was measured with Cap'n
Web's serialize(), even plain JSON, which the journal stores as JSON
anyway. Two results that a plain host module takes then failed: JSON
nested past 256 levels ("Serialization exceeded maximum allowed
depth"), such as a 128-level DOM.getDocument result, and text whose
JSON escaping pushed it over the byte limit.
Results are now measured the way replayable requests already are:
plain data by its raw size, and only richer values by their encoding.
A value with anything richer in it is still stored whole with Cap'n
Web's encoding, so measuring also checks that the whole value
encodes. A request or result too deep for the journal is then the
call's error, rather than a failure when the journal stores it.
Only objects can be released early, so a scoped context's dispose is never told "disposed". Its end type still allowed it, so checking `end.reason !== "paused"` didn't narrow to the reasons that have log(), and the docs' example didn't compile. dispose now takes CodemodeContextScopeEnd, which leaves "disposed" out, and the test module drops its extra check.
A method that awaits a scoped context carried on after its call had timed out or been cancelled, if the context was slow to start. The caller had already been told the call failed, but the method could still act, such as writing through a session it never should have used. The scoped context's getter now checks the call's signal once the context has started, so the method's await throws instead.
ben-reitz
force-pushed
the
browser/codemode-module-fixes
branch
from
November 4, 2026 10:55
0a30691 to
832bfc8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes for #301, one commit each, so any of them can be taken on its own. They came up while porting the
codemode:browsermodule (#299) ontocreateCodemodeModule().If you want to review the code, i suggest doing it commit-by-commit as the fixes were committed one-by-one.
1. Measure plain results as plain data in replayable runs
In a replayable run, every codemode result was measured by encoding it with Cap'n Web, even plain JSON. That changed what fits inside the limits:
DOM.getDocumenton a 128-level pageSerialization exceeded maximum allowed depthResults are now measured like replayable requests already are: plain data at its raw size, and only values like a
Dateby their encoding. When a value does contain one of those, the journal stores it whole with Cap'n Web, so measuring now also checks that it encodes. Otherwise a deep tree with aDatein it would fail later, when the journal stores it, instead of returning an error to the call.2. Leave
"disposed"out of a scoped context's dispose reasonsOnly objects get
"disposed", but a context'sdisposewas typed to get it too, which breaks the check:disposenow takesCodemodeContextScopeEnd, which leaves"disposed"out.3. Stop a method once its call has timed out
If a scoped context was slow to start, the caller was told the call timed out, but the method carried on after
await ctx.session. The getter now checks the call's signal once the context starts, so every module gets the check without having to add it.