Skip to content

fix(user-transformations): preserve log in cached V1 contexts - #5637

Merged
gitcommitshow merged 1 commit into
developfrom
harness/MAR-2930-fix-user-transformations-preser-74c0fded
Oct 14, 2026
Merged

gitcommitshow merged 1 commit into
developfrom
harness/MAR-2930-fix-user-transformations-preser-74c0fded

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Inject the documented log runtime function when resetting cached V1 isolated-vm contexts. Add focused context-reset coverage and an end-to-end regression proving a Jev-style fail-open branch returns the original event on both cache miss and cache hit.

What is the related Linear task?

Resolves MAR-2930

Please explain the objectives of your changes below

Runtime reproduction showed that the first V1 execution succeeds because ivmFactory.js defines log, but the second execution with USE_IVM_CACHE=true failed with ReferenceError: log is not defined because context reset did not restore it. This change restores parity without changing the broader sandbox architecture.

The remaining Jev template findings—including Unicode-safe redaction, identify traits, Bot Management merge semantics, response validation, credential behavior, and upstream byte identity—belong to the dependent rudder-control-plane change.

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

Cached V1 transformations can now call log(...) after context reset. In production it remains a non-throwing no-op, matching fresh V1 isolates.

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

The cached-isolate context reset now restores the existing V1 log runtime global alongside the other sandbox APIs.

Any technical or performance related pointers to consider with the change?

The injected function is a no-op and is recreated once per reset context. No logging payload is retained or transferred.


Developer checklist

  • My code follows the style guidelines of this project
  • No breaking changes are being introduced.
  • All related docs linked with the PR? N/A; runtime documentation already lists log.
  • All changes manually tested?
  • Any documentation changes needed with this change? No.
  • Is the PR limited to 10 file changes?
  • Is the PR limited to one linear task?
  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?
  • Verified that there are no credentials or confidential data exposed with the changes.

Validation

  • npm run lint — passed.
  • NODE_OPTIONS='--no-node-snapshot' npx jest -c jest.default.config.js test/__tests__/ivmCache/contextReset.test.js test/__tests__/user_transformation.test.js --runInBand --no-coverage — passed.
  • NODE_OPTIONS='--no-node-snapshot' npx jest -c jest.default.config.js test/__tests__/user_transformation.test.js --runInBand -t "keeps log available" — exit 0; 1 focused test passed after reproducing ReferenceError: log is not defined on the unmodified runtime.

🔭 Live preview

Resumable while this task is open.

@rudder-devbox

rudder-devbox Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

👋 I'm rudder-devbox. I opened this PR from a Linear ticket.

Mention @devbox or @rudder-devbox and I'll act on it — on a top-level PR comment,
in a review summary, or on an inline comment on the diff. Without a mention I won't see it.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 58a402b8-0629-4099-84ef-c94d1364d512

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.11%. Comparing base (61cc122) to head (9adbab6).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5637   +/-   ##
========================================
  Coverage    92.11%   92.11%           
========================================
  Files          708      708           
  Lines        39529    39530    +1     
  Branches      9194     9263   +69     
========================================
+ Hits         36412    36413    +1     
  Misses        2932     2932           
  Partials       185      185           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gitcommitshow
gitcommitshow marked this pull request as ready for review October 8, 2026 06:08
@gitcommitshow
gitcommitshow requested review from a team as code owners October 8, 2026 06:08
@gitcommitshow
gitcommitshow force-pushed the harness/MAR-2930-fix-user-transformations-preser-74c0fded branch from e4ec74a to dbeec57 Compare October 8, 2026 06:08
@gitcommitshow
gitcommitshow requested review from MiteshSharma and a balanced review from Copilot October 8, 2026 06:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitcommitshow
gitcommitshow enabled auto-merge (squash) October 12, 2026 15:21
@gitcommitshow
gitcommitshow force-pushed the harness/MAR-2930-fix-user-transformations-preser-74c0fded branch from dbeec57 to 9adbab6 Compare October 12, 2026 15:22
@sonarqubecloud

Copy link
Copy Markdown

@gitcommitshow
gitcommitshow merged commit baf5d6a into develop Oct 14, 2026
48 checks passed
@gitcommitshow
gitcommitshow deleted the harness/MAR-2930-fix-user-transformations-preser-74c0fded branch October 14, 2026 14:53
@sivashanmukh

Copy link
Copy Markdown
Contributor

Follow-up: root cause is two separate lists of sandbox globals. Fixed in #5675.

createIvm in src/util/ivmFactory.js and injectFreshApis in src/util/ivmCache/contextReset.js each kept their own copy of the host APIs injected into the isolate. This PR fixed the one global that had drifted (log, missing since #4675), but the next global added to createIvm would drift the same way.

#5675 moves the injection into a single injectSandboxApis in src/util/ivmSandboxApis.js, which both paths call. The cache-hit regression test from this PR now asserts that a cache miss and a cache hit see the same Object.getOwnPropertyNames(globalThis). I also gave the test a neutral name instead of the customer template name.

@sivashanmukh

Copy link
Copy Markdown
Contributor

Follow-up: the no-op log still copies its arguments into the host. Fixed in #5675.

Outside test mode, log is a host callback that does nothing, in both the fresh and the cached path. isolated-vm still deep-copies every argument into host memory before calling it. That memory is outside the isolate's memoryLimit, and the copy runs synchronously on the host, so log(hugeObject) in a loop costs host memory and CPU and produces nothing. Uncloneable arguments also throw. I checked this against [email protected]: log(() => 1) and log(Symbol()) throw ... could not be cloned. So "non-throwing" in this PR's description holds only for cloneable values.

#5675 injects the host log only in test mode, where it captures output. Otherwise the bootstrap script defines global.log = function () {} inside the isolate, so production calls never cross the boundary.

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.

5 participants