AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

WASM CodeFrameColumns Rejects Boolean Color And Undefined MaxWidth, Hiding Real Errors

On the WASM SWC bindings, codeFrameColumns deserializes options directly into a strict CodeFrameOptions struct that cannot accept boolean color or undefined maxWidth, unlike the native N-API binding. This causes 100% of code frames to fail on the WASM fallback, replacing the actual error with a serialization error in the dev overlay, server console, and build diagnostics.

highConfidence 85%Next.jsReact Server ComponentsHydrationnext buildAffected V16.3.5Affected V16.4.0-Canary.51

Origin Analysis

The WASM binding in crates/wasm/src/lib.rs uses serde_wasm_bindgen::from_value to deserialize JS options straight into CodeFrameOptions, whose fields are typed as CodeFrameColorMode and usize. serde(default) only applies to missing fields, not explicit boolean/undefined values. The N-API binding uses a tolerant option struct with Either<enum, bool> and Option<usize>, but the WASM path lacks this normalization.
1. Create a Next.js app with next@canary and force WASM bindings (NEXT_TEST_WASM=1, NEXT_TEST_WASM_DIR=node_modules/@next/swc-wasm-nodejs). 2. Run npm run repro to call codeFrameColumns with the four option shapes Next.js itself passes; three throw. 3. Run npm run dev -- --webpack, open http://localhost:3000/trigger-error, observe the dev overlay missing the code frame and server console showing only the binding error. 4. Open the API route equivalent to see the real error never reaching the console. 5. Compare with native bindings where code frames render correctly.

Fixing Code Block

Edge Case Audit

This change only affects the WASM path. If CodeFrameOptions gains new fields in future versions, WasmCodeFrameOptions must be updated accordingly. Rolling back is safe: revert the commit to restore the original deserialization. Ensure the default values for lines_above, lines_below, and max_width match the native binding's defaults to avoid behavioral differences across bindings. Test on OpenBSD/other platforms where native binaries are unavailable.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state