Repository navigation
Preview: a value JSON has no form for no longer ends the app on macOS and iOS, and a script's error is reported - #1200
Merged
Conversation
… and iOS, and a script's error is reported preview_evaluate went through lb-wry's evaluation callback, which gives WebKit's result object to NSJSONSerialization. That raises on a NaN, an infinity or a Date anywhere in the value, and the exception ends the process. The callback also drops the error WebKit reports, so a syntax error or a thrown exception came back as an empty string. On macOS and iOS Tcode now calls evaluateJavaScript itself: the page makes the JSON of its value, which is what WebView2, Android and WebKitGTK already hand back, and WebKit's error is the call's error.
Tryanks
force-pushed
the
claude/preview-evaluate-crash
branch
from
November 27, 2026 01:45
bbf0beb to
3944a96
Compare
Tryanks
enabled auto-merge
November 27, 2026 01:49
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.
Summary
On macOS and iOS a
preview_evaluatewhose value held a NaN, an infinity or aDateended the whole app. 0.5.1 went down this way on[window.__tr, Date.now()-window.__tt], where__ttwas undefined.The cause is in lb-wry 0.53.3: its evaluation callback gives WebKit's result object to
NSJSONSerialization, which raises on a value JSON has no form for, and nothing catches the exception. The same callback drops theNSErrorWebKit reports, so a syntax error or a thrown exception came back as"". Tcode carries it at the owner of the evaluation, on these two platforms only:The page makes the JSON, which is what WebView2, Android and WebKitGTK already hand back from the engine, so no Foundation serialization is left on the path.
What an agent sees differently on macOS and iOS:
js[undefined, NaN][null, null]Infinity,new Date(0)NSJSONSerializationraises on both when called alonenull,"1970-01-01T00:00:00.000Z"window.__tt=1; 2""SyntaxError: Unexpected token ';'. …(()=>{throw new Error("boom")})()""Error: boomnew Promise(…)""{}10nTypeError: JSON.stringify cannot serialize …document.body{}preview panel dropped request; by lb-wry's source the script then runs unheard at the next navigation, which was not observedlocation.href→"about:blank"Not changed: on Linux lb-wry still answers a script's error with
"", and WebView2 and Android report it as their engines do.Evidence
Both builds are
tcodedebug builds on a throwawayTCODE_DATA_DIR, macOS 27.2.1, each with a real thread and a realWKWebViewondata:text/html,<title>t</title><p>hi</p>; the calls aretools/callrequests to the thread's own preview MCP server.ed81cdc50):preview_snapshotanswering after the page had replacedJSON.stringify:cargo fmt --all --check,cargo clippy --workspace --all-targets --locked -- -D warningsandcargo nextest run --workspace --locked(1514 passed) on macOS;RUSTFLAGS='-D warnings' cargo check -p tcode-ios --target aarch64-apple-ios-sim --locked. iOS is compiled, not run.No test is added. What failed is WebKit's result meeting Foundation, which only a real engine shows; a test of the wrapper's text would assert a string the code under test writes.
Merge Danger
Door: two-way
Blast Radius:
preview_evaluateon macOS and iOSAn agent that relied on
""for a failing expression now gets a tool error instead.