Skip to content

fix(ext/web): support %j JSON format specifier in console.log#32684

Merged
bartlomieju merged 2 commits intodenoland:mainfrom
bartlomieju:fix/console-json-format-specifier
Mar 13, 2026
Merged

fix(ext/web): support %j JSON format specifier in console.log#32684
bartlomieju merged 2 commits intodenoland:mainfrom
bartlomieju:fix/console-json-format-specifier

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

  • Add support for the %j format specifier in console.log and related methods, which JSON-stringifies the argument (matching Node.js behavior)
  • Circular references output [Circular] instead of throwing

Closes #32680

Test plan

  • Added unit tests for %j with objects, primitives, arrays, multiple specifiers, and circular references
  • ./x test-unit console passes

🤖 Generated with Claude Code

Closes denoland#32680

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only catch circular reference TypeError in %j JSON formatting,
re-throwing other errors (e.g. BigInt) instead of swallowing them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bartlomieju bartlomieju enabled auto-merge (squash) March 13, 2026 11:31
Copy link
Copy Markdown
Member

@crowlKats crowlKats left a comment

Choose a reason for hiding this comment

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

LGTM

@bartlomieju bartlomieju merged commit 6c5ef85 into denoland:main Mar 13, 2026
220 of 222 checks passed
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.

node:console does not support JSON format in console.log

3 participants