Skip to content

chore(rivetkit): remove legacy metrics#4723

Closed
NathanFlurry wants to merge 1 commit into04-23-chore_rivetkit_impl_inspector_tokenfrom
chore_rivekit_actions
Closed

chore(rivetkit): remove legacy metrics#4723
NathanFlurry wants to merge 1 commit into04-23-chore_rivetkit_impl_inspector_tokenfrom
chore_rivekit_actions

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 Apr 24, 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

claude Bot commented Apr 24, 2026

PR Review: chore(rivetkit): remove legacy metrics

Summary

This PR does three largely independent things:

  1. Removes the metricsResponse closure and the GET /inspector/metrics HTTP route from native.ts.
  2. Adds an actions field to ActorConfig / ActorConfigInput / JsActorConfig, threads it through the NAPI bridge, and uses it to populate inspector_rpcs in rivetkit-core.
  3. Renames the test-only inspector token env var from RIVET_INSPECTOR_TOKEN to _RIVET_TEST_INSPECTOR_TOKEN in buildNativeRegistry.
  4. Adds three performance.now() debug log timings around createState, createVars, and onWake.

Issues

1. Orphaned tests for the deleted /inspector/metrics endpoint (significant)

rivetkit-typescript/packages/rivetkit/tests/driver/actor-inspector.test.ts contains tests that assert on the now-deleted GET /inspector/metrics route. After this PR those tests will receive a 404 and fail. They were not removed or updated.

2. _RIVET_TEST_INSPECTOR_TOKEN rename appears half-complete

buildNativeRegistry in native.ts now sets _RIVET_TEST_INSPECTOR_TOKEN, and the Rust inspector tests at rivetkit-rust/packages/rivetkit-core/tests/modules/inspector.rs already use _RIVET_TEST_INSPECTOR_TOKEN. However rivetkit-rust/packages/rivetkit-core/src/inspector/auth.rs continues to read only RIVET_INSPECTOR_TOKEN. The _RIVET_TEST_INSPECTOR_TOKEN variable set by the TypeScript test harness will never be observed by the Rust auth path, so inspector auth will silently fail in test mode.

3. Dual RPC list computation that can silently diverge

buildActorConfig now builds actions from Object.keys(config.actions).sort() and passes it to Rust for inspector_rpcs. The JS-side /inspector/rpcs HTTP handler in native.ts independently re-derives the list with Object.keys(actionHandlers).sort(). If one is updated without the other, the RPC lists seen by the WebSocket inspector broadcast path (Rust) and the HTTP path (TypeScript) will diverge. Ideally the JS path should delegate to the Rust-side config, or at minimum share a constant.

4. Redundant startup timing logs

The three new performance.now() debug logs in the native path (for createState, createVars, onWake) duplicate logs already emitted by the JS ActorInstance.#measureStartup for the same phases. This produces double entries in log output and may confuse tooling.

5. config.actions cast suppresses future type safety

In buildActorConfig: (config.actions ?? {}) as Record<string, unknown>. The intermediate cast to Record<string, unknown> suppresses any type error if config.actions is ever given a non-object type in the future. A narrower cast or explicit type guard would be safer.


Positive observations

  • Removing metricsResponse eliminates a large block of hardcoded stub data (startup metrics all returning 0 or 1). The cleanup is welcome.
  • Threading actions through ActorConfigInput → ActorConfig → inspector_rpcs is the correct approach per the layer architecture (inspector logic belongs in rivetkit-core).
  • The From<JsActorConfig> for ActorConfigInput conversion correctly maps JsActionDefinition → ActionDefinition without leaking NAPI types into core.
  • The .sort() in buildActorConfig ensures deterministic ordering, consistent with the existing JS /inspector/rpcs sort.

Verdict

The most important issues to address before merging are #1 (orphaned metrics tests will fail CI), #2 (env-var rename appears half-complete and may silently break inspector auth in test mode), and #3 (dual RPC list computation that can silently diverge). Issues #4#5 are lower severity.

@github-actions
Copy link
Copy Markdown
Contributor

Preview packages published to npm

Install with:

npm install rivetkit@pr-4723

All packages published as 0.0.0-pr.4723.8dd3380 with tag pr-4723.

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-8dd3380
docker pull rivetdev/engine:full-8dd3380
Individual packages
npm install rivetkit@pr-4723
npm install @rivetkit/react@pr-4723
npm install @rivetkit/rivetkit-napi@pr-4723
npm install @rivetkit/workflow-engine@pr-4723

@NathanFlurry NathanFlurry force-pushed the 04-23-chore_rivetkit_impl_inspector_token branch from 3b9f382 to d88d866 Compare April 24, 2026 09:52
@NathanFlurry NathanFlurry force-pushed the chore_rivekit_actions branch from df59472 to 8f5aeb9 Compare April 24, 2026 09:52
@NathanFlurry NathanFlurry mentioned this pull request Apr 24, 2026
11 tasks
@NathanFlurry NathanFlurry force-pushed the chore_rivekit_actions branch from 8f5aeb9 to f8e2ea7 Compare April 24, 2026 10:19
@NathanFlurry NathanFlurry force-pushed the 04-23-chore_rivetkit_impl_inspector_token branch from 136e91f to f06fea6 Compare April 24, 2026 10:32
@NathanFlurry NathanFlurry force-pushed the chore_rivekit_actions branch from f8e2ea7 to bb871d1 Compare April 24, 2026 10:32
@NathanFlurry NathanFlurry force-pushed the 04-23-chore_rivetkit_impl_inspector_token branch from f06fea6 to c1a28bb Compare April 24, 2026 11:48
@NathanFlurry NathanFlurry force-pushed the chore_rivekit_actions branch from bb871d1 to 338f37e Compare April 24, 2026 11:48
@NathanFlurry NathanFlurry force-pushed the 04-23-chore_rivetkit_impl_inspector_token branch from c1a28bb to bec342f Compare April 24, 2026 12:14
@NathanFlurry NathanFlurry force-pushed the chore_rivekit_actions branch from 338f37e to a1adf67 Compare April 24, 2026 12:14
@NathanFlurry NathanFlurry force-pushed the 04-23-chore_rivetkit_impl_inspector_token branch from bec342f to c4929c6 Compare April 24, 2026 12:32
@NathanFlurry NathanFlurry force-pushed the chore_rivekit_actions branch from a1adf67 to 0df30ed Compare April 24, 2026 12:32
@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