Skip to content

fix(rivetkit): move ActorInspector init to constructor body#4124

Open
NathanFlurry wants to merge 1 commit into02-03-feat_use_casesfrom
02-05-fix_rivetkit_move_actorinspector_init_to_constructor_body
Open

fix(rivetkit): move ActorInspector init to constructor body#4124
NathanFlurry wants to merge 1 commit into02-03-feat_use_casesfrom
02-05-fix_rivetkit_move_actorinspector_init_to_constructor_body

Conversation

@NathanFlurry
Copy link
Member

@NathanFlurry NathanFlurry commented Feb 5, 2026

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

@railway-app
Copy link

railway-app bot commented Feb 5, 2026

🚅 Deployed to the rivet-pr-4124 environment in rivet-frontend

Service Status Web Updated (UTC)
website ❌ Build Failed (View Logs) Web Feb 5, 2026 at 8:37 am
frontend-cloud ❌ Build Failed (View Logs) Web Feb 5, 2026 at 8:36 am
frontend-inspector ❌ Build Failed (View Logs) Web Feb 5, 2026 at 8:36 am
mcp-hub ✅ Success (View Logs) Web Feb 5, 2026 at 8:36 am

This was referenced Feb 5, 2026
Copy link
Member Author

NathanFlurry commented Feb 5, 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


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

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

@claude
Copy link

claude bot commented Feb 5, 2026

Code Review

Summary

This PR moves the ActorInspector initialization from a class field initializer to the constructor body in ActorInstance. This is a small but important fix that addresses a potential initialization order issue.

Analysis

What Changed:

  • Before: #inspector = new ActorInspector(this) (field initializer)
  • After: #inspector!: ActorInspector (field declaration) + initialization in constructor body

Why This Matters:

  1. Initialization Order: In TypeScript/JavaScript, class field initializers run before the constructor body executes. When ActorInspector is initialized as a field, it receives this before the constructor has finished setting up the instance.

  2. Incomplete State: The ActorInspector constructor accesses actor.config.run and actor.queueManager. If these properties are not fully initialized when the field initializer runs, it could lead to undefined behavior.

  3. Proper Fix: Moving initialization to the constructor body (after this.#config = config) ensures that all dependencies are properly set up before ActorInspector is created.

Code Quality: ✅ Good

  • Correct pattern: Uses the definite assignment assertion (!) appropriately
  • Follows conventions: Matches the pattern used for other fields like #schedule, #traces
  • Minimal change: Touches only what is necessary

Potential Issues: ✅ None Found

  • No bugs identified
  • No race conditions or timing issues
  • The inspector getter will work correctly since it is only called after construction

Performance: ✅ Neutral

  • No performance impact - just reordering initialization

Security: ✅ No Concerns

Test Coverage: ⚠️ Consider Adding

Recommendation: Consider adding a test that verifies the inspector is properly initialized with the correct config and queue state. This would prevent regression if someone moves the initialization back to a field initializer.

Verdict: ✅ LGTM

This is a solid bug fix that prevents potential initialization order issues. The change is minimal, correct, and follows existing patterns in the codebase.

Minor Suggestion: Consider adding a comment explaining why this initialization happens in the constructor rather than as a field initializer to help prevent future refactoring from reintroducing the issue.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

More templates

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4124

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4124

@rivetkit/db

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/db@4124

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4124

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4124

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4124

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4124

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4124

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4124

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4124

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4124

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4124

commit: 6d0f317

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