Skip to content

fix(core): keep toJSON hidden fields hidden on a second set() - #899

Closed
evlogai[bot] wants to merge 2 commits into
mainfrom
EVL-689/backport-writable-child-tojson
Closed

evlogai[bot] wants to merge 2 commits into
mainfrom
EVL-689/backport-writable-child-tojson

Conversation

@evlogai

@evlogai evlogai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Written by an AI agent on behalf of @HugoRCD. @HugoRCD has not reviewed it yet.

Refs EVL-689

Summary

Ports the writableChild change from #894 to main. #894 landed on v3, where the fix is already present. This branch brings it to main before 2.33.0 so the regression never ships.

When log.set() merges into a key that already holds a plain object, writableChild copies that object with a spread. A spread drops a non-enumerable toJSON, so the copy lost the method that hid a field. A second set() on the same key then exposed the hidden field. The copy now keeps toJSON.

Scope is limited to packages/evlog/src/logger.ts, its regression test, and one changeset. No other change from #894 is ported.

Before and after

Input, logged twice under the same key:

const payload = { visible: 1, secret: 'hunter2' }
Object.defineProperty(payload, 'toJSON', { value: () => ({ visible: 1 }), enumerable: false })
logger.set({ payload })
logger.set({ payload: { extra: 2 } })
JSON.stringify(logger.getContext().payload)
- {"visible":1,"secret":"hunter2","extra":2}   (main at e9df2a5)
+ {"visible":1}                                 (this branch)

Checks

  • The regression test is its own commit (9ccfe4f). On main it fails with Received: {"visible":1,"secret":"hunter2","extra":2}. With the fix it passes.
  • pnpm run typecheck: 30 of 30 tasks green.
  • pnpm run lint: 25 of 25 tasks green.
  • pnpm --filter evlog run test: 119 files, 2288 tests pass.
  • pnpm --filter @evlog/signals run test: 5 files, 32 tests pass. In the first full-workspace run this package hit a vitest worker startup timeout under parallel load. It passes when run alone, and it does not depend on logger.ts.
  • I did not get one clean run of the full-workspace pnpm run test; the per-package runs above are what I can vouch for.

Changeset

"evlog": patch: log.set() no longer exposes fields hidden by a toJSON method when the same key is set twice (regression in an unreleased change).

Release order

This should merge before #858. Once it lands on main, the Changesets action refreshes #858 with the new entry.

ELI5

Our logger copies an object before adding to it. The copy forgot a hidden rule that says "don't show this field". So if you added data to the same object twice, the hidden field showed up in the logs. This change keeps that rule on the copy, so hidden fields stay hidden.

@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
evi Ready Ready Preview Oct 17, 2026 2:51pm UTC
evlog-docs Ready Ready Preview, v0 Oct 17, 2026 2:51pm UTC
evlog-render-lab Ready Ready Preview Oct 17, 2026 2:51pm UTC
evlog-telemetry Ready Ready Preview Oct 17, 2026 2:51pm UTC
just-use-evlog Ready Ready Preview Oct 17, 2026 2:51pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 547bdeae-0ae7-4be8-9960-f27bdbcf4c95

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.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@evlogai

evlogai Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Closing this as superseded. #898 already merged the same writableChild change and regression test into main (396f7b1, 14:49 UTC), a few minutes before this PR was opened. This branch now conflicts with main and would duplicate that work, so nothing here is needed. Refs EVL-689.

ELI5

Another run of the same fix landed on the main branch just before this one. This copy would only clash with it, so it is being closed. The fix is already on the main branch.

@evlogai evlogai Bot closed this Oct 17, 2026

This branch was successfully deployed

5 active deployments
Preview – evlog-telemetry — ec559ffa Deployed Oct 17, 2026 by vercel[bot]
Preview – evi — ec559ffa Deployed Oct 17, 2026 by vercel[bot]
Preview – evlog-docs — ec559ffa Deployed Oct 17, 2026 by vercel[bot]
Preview – just-use-evlog — ec559ffa Deployed Oct 17, 2026 by vercel[bot]
Preview – evlog-render-lab — ec559ffa Deployed Oct 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants