Skip to content

feat(js): add JavaScript function tracer with Babel instrumentation#2105

Merged
KRRT7 merged 1 commit intomainfrom
feat/js-tracer-rebase-v2
Apr 23, 2026
Merged

feat(js): add JavaScript function tracer with Babel instrumentation#2105
KRRT7 merged 1 commit intomainfrom
feat/js-tracer-rebase-v2

Conversation

@KRRT7
Copy link
Copy Markdown
Collaborator

@KRRT7 KRRT7 commented Apr 23, 2026

Linked issue or discussion

Supersedes #1377 — reimplemented against current main after the original branch diverged too far to rebase (78 days, conflicts in 4+ files).

What changed

Adds function tracing for JavaScript/TypeScript projects, matching the existing Python tracer architecture.

How it works:

  1. A Babel plugin (babel-tracer-plugin.js) instruments JS/TS functions at runtime by wrapping them with __codeflash_tracer__.wrap() calls — no source modification needed
  2. The tracer (tracer.js) records function calls with nanosecond timing and serialized arguments to a SQLite database
  3. After tracing, the replay module (replay.js) reads the trace DB and generates Jest/Vitest test files that replay the captured calls
  4. Python-side orchestration (tracer_runner.py, replay_test.py) spawns the Node.js tracer subprocess and converts trace data into codeflash's test format

CLI integration:

  • codeflash trace --language javascript routes to the JS tracer
  • Language is auto-detected from project config if not specified

Deferred:

Test plan

  • 21 unit tests in test_javascript_tracer.py covering trace parsing, replay test generation, and E2E tracing
  • Added to js-tests.yml CI workflow
  • Updated test_javascript_instrumentation.py to reflect that Babel handles instrumentation at runtime (no more source-level instrument_source())

Replaces source-level JavaScript function tracing with Babel AST
transformation via babel-tracer-plugin.js and trace-runner.js. Adds
replay test generation, Python-side tracer runner, and --language
flag to the tracer CLI for explicit JS/TS routing.
@KRRT7 KRRT7 merged commit dc5090e into main Apr 23, 2026
30 of 32 checks passed
@KRRT7 KRRT7 deleted the feat/js-tracer-rebase-v2 branch April 23, 2026 10:00
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