Skip to content

fix(rivetkit): align logs with engine logfmt#4933

Closed
NathanFlurry wants to merge 8 commits intographite-base/4933from
05-04-fix_rivetkit_align_logs_with_engine_logfmt
Closed

fix(rivetkit): align logs with engine logfmt#4933
NathanFlurry wants to merge 8 commits intographite-base/4933from
05-04-fix_rivetkit_align_logs_with_engine_logfmt

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented May 4, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 4, 2026

Code Review: fix(rivetkit): align logs with engine logfmt

Overview

This PR aligns the log format output for the NAPI/TypeScript layers with the engine's logfmt format. It adds logfmt (and GCP/Stackdriver) support on the Rust side via tracing-logfmt / tracing-stackdriver, and implements a custom pino logfmt destination on the TypeScript side.


Rust

Generally solid. The conditional layer pattern with Option<SomeLayer> is the idiomatic way to toggle tracing-subscriber layers of different types.

Minor issues:

  • env_flag only accepts "1" as truthy. Worth ensuring this is consistent with how the engine reads similar flags.
  • RIVET_LOG_TARGET and RUST_LOG_TARGET are OR'd in Rust, but the TypeScript side reads RIVET_LOG_TARGET via getLogTarget() from env-vars.ts and does not use it in the new logfmt destination. Minor asymmetry worth noting.

TypeScript

The overall approach (parse pino JSON output, reformat as logfmt) works, but there are correctness and robustness gaps.

Potential bug: incomplete control character escaping in quoteLogfmtString

Only \n is escaped inside quoted strings. \r and \t will be embedded literally, producing multi-line output that breaks downstream log parsers.

Missing flushSync on the destination stream. Pino may call flushSync() on graceful shutdown. Without it, the last log lines before process exit may be lost. A no-op flushSync(): void {} satisfies the interface.

Objects/arrays become opaque JSON strings. formatLogfmtValue falls through to quoteLogfmtString(JSON.stringify(value)) for objects. Functionally correct but less readable than what tracing-logfmt produces on the Rust side. Nice-to-have, not a blocker.

No test coverage. The formatLogfmtLine / quoteLogfmtString / appendLogfmtEntry helpers are pure functions that are easy to unit-test.


Summary

Severity Issue
Bug quoteLogfmtString does not escape \r/\t and can produce multi-line logfmt output
Minor No flushSync on pino destination; last lines may be dropped on graceful exit
Minor env_flag only accepts "1"; may be inconsistent with ops tooling
Nit RIVET_LOG_TARGET unused in new TS logfmt destination (Rust side checks it)
Suggestion No unit tests for the logfmt formatting helpers

The control character escaping issue is the only real bug. Everything else is minor. The overall approach is clean and consistent with the engine's logging patterns.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Preview packages published to npm

Install with:

npm install rivetkit@pr-4933

All packages published as 0.0.0-pr.4933.5484e59 with tag pr-4933.

Engine binary is shipped via @rivetkit/engine-cli on linux-x64-musl, linux-arm64-musl, darwin-x64, and darwin-arm64. Windows users should use the release installer or set RIVET_ENGINE_BINARY.

Docker images:

docker pull rivetdev/engine:slim-5484e59
docker pull rivetdev/engine:full-5484e59
Individual packages
npm install rivetkit@pr-4933
npm install @rivetkit/react@pr-4933
npm install @rivetkit/rivetkit-napi@pr-4933
npm install @rivetkit/workflow-engine@pr-4933

@NathanFlurry
Copy link
Copy Markdown
Member Author

Landed in main via stack-merge fast-forward push. Commits are in main; closing to match.

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