Skip to content

Remap TypeScript runtime stacks with source maps - #146

Draft
noise64 wants to merge 17 commits into
mainfrom
gol-419-typescript-stack-source-maps
Draft

Remap TypeScript runtime stacks with source maps#146
noise64 wants to merge 17 commits into
mainfrom
gol-419-typescript-stack-source-maps

Conversation

@noise64

@noise64 noise64 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
  • resolves https://linear.app/golem-cloud/issue/GOL-419
  • generates and registers runtime-local source maps for transformed ESM, CommonJS, public transform, and execution-job paths
  • uses one lexical sourceMappingURL parser for CJS and vm.Script, preserving trailing lines while rejecting string, template, regex, block-comment, and trailing-garbage decoys
  • remaps Error stacks and util.getCallSites() while preserving the native Error constructors, subclass relationships, constructorOpt, low stack limits, and guest prepareStackTrace descriptors
  • keeps QuickJS's existing eager hook timing for ordinary Error construction; explicit Error.captureStackTrace() captures native CallSites immediately and selects the public hook lazily on first .stack access
  • keeps executable CJS registration with compileCjs, bounds map retention, and synchronizes Rust/JavaScript inline-map emitters
  • matches Node.js 22.14 inline-map output: a blank line precedes inline maps and sourceMap: true suppresses a separate sourceURL
  • removes the JavaScript Error-constructor wrappers that could fault inside QuickJS backtrace construction and adds focused header/descriptor regressions
  • adapts QuickJS CallSites whose native toString() is only [object CallSite], preserving named, anonymous, and native-frame formatting
  • keeps the first prepared result for each ordinary Error in a weak cache so later QuickJS propagation callbacks cannot replace the original throw-site stack
  • refreshes a native Error header during util.inspect only when the current stack is the exact cached native prepared result, matching later name changes without rewriting manually assigned stacks
  • removes source-callsite-based util.inspect constructor inference, which could be spoofed by nearby source text and could not recover names from stored-variable calls; the V8 hidden-class-only case is retained as an explicit known gap
  • regenerates the V8 stack DTS declaration and removes a platform-dependent 25 ms assertion from ordinary runtime tests

Node compatibility

  • enables the supported source-map API block while retaining honest child-process, CLI, worker, and QuickJS timing/refcount gaps
  • checked-in combined report: 3180/4388 primary CI-enforced and 3180/5750 full public
  • the combined regeneration also reconciles compatibility classifications merged independently on main

At local merged candidate SHA 7906591aa44fda65ba5c315fa5eb794849947692, formatting, DTS generation/verification, cargo build --all-targets, and workspace cargo clippy --all-targets -- -Dwarnings pass. Sixteen focused runtime cases pass in both P2 and P3, covering the original module-resolution backtrace crash, V8 stack behavior, source maps, and TypeScript constructor/descriptor stability; final V8-only reruns pass 13/13 on both paths. The three exact Node.js 22.14 cases that failed the earlier CI run pass 3/3 in both P2 and P3. The subsequent V8 hidden-class-only test-util-inspect.js#block_73 case is now an explicit known gap after rejecting a source-shaped workaround; the remaining family passes on P2 and P3 (47 passed, 52 ignored, 0 failed per path). The combined compatibility report and all five CI report-contract checks pass. Seven targeted #143 P3 stream-lifecycle cases pass after integrating current main through a normal merge. The final current-name/manual-stack regression passes on both P2 and P3. Standalone skeleton Clippy still reports pre-existing warnings in module_loading.rs, outside this correction.

@blacksmith-sh

This comment has been minimized.

@noise64
noise64 changed the base branch from gol-418-single-cjs-ts-transform to main September 4, 2026 17:59
…ack-source-maps-final

# Conflicts:
#	tests/node_compat/report.md
…ack-source-maps-final

# Conflicts:
#	tests/node_compat/report.md
…ack-source-maps-current

# Conflicts:
#	crates/wasm-rquickjs/skeleton/src/builtin/execution.rs
#	crates/wasm-rquickjs/skeleton/src/internal/module_loading.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant