-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(hub): add separate protocol for actor inspect #1946
feat(hub): add separate protocol for actor inspect #1946
Conversation
Deploying rivet-hub with Cloudflare Pages
|
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.
How to use the Graphite Merge QueueAdd 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. |
Deploying rivet with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR introduces a separate protocol for actor inspection, significantly refactoring the actor communication and inspection mechanisms across the codebase.
- Critical logical error in
frontend/apps/hub/src/domains/project/components/actors/actors-actor-details.tsx
whereenabled={!data.destroyedAt || !data.endpoint}
should likely beenabled={!data.destroyedAt && data.endpoint}
to properly handle actor state - New
ActorInspection
class insdks/actor/runtime/src/inspect.ts
needs improved error handling for WebSocket connection failures and resource cleanup - Potential type safety issue in
frontend/apps/hub/src/domains/project/queries/actors/query-options.ts
with undocumented URL property using ts-ignore flags - Added
[INSPECT_SYMBOL]()
insdks/actor/runtime/src/connection.ts
improves encapsulation but should include documentation for symbol usage - New
validateMessageEvent
andhandleMessageEvent
functions insdks/actor/runtime/src/event.ts
need additional error cases for malformed messages
13 file(s) reviewed, 11 comment(s)
Edit PR Review Bot Settings | Greptile
frontend/apps/hub/src/domains/project/components/actors/actors-actor-details.tsx
Outdated
Show resolved
Hide resolved
frontend/apps/hub/src/domains/project/components/actors/worker/actor-worker-context.tsx
Show resolved
Hide resolved
35845f3
to
ef5887d
Compare
cc63118
to
ac2e9de
Compare
ef5887d
to
1e1fc74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR continues the implementation of a separate protocol for actor inspection, focusing on the actor runtime and connection handling components.
- Added throttling mechanism in
sdks/actor/runtime/src/inspect.ts
for state and connection change notifications to prevent excessive updates - Improved error handling in
sdks/actor/runtime/src/actor.ts
with newUnsupported
error class for feature-specific failures - Refactored
ActorWorkerContainer
infrontend/apps/hub/src/domains/project/components/actors/worker/actor-worker-container.ts
to use direct endpoints instead of manager URLs - Added dedicated
inspectLogger
insdks/actor/runtime/src/log.ts
for better debugging of inspection-related operations - Implemented proper cleanup in
sdks/actor/runtime/src/actor.ts
for WebSocket connections with a 1.5 second timeout
13 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile
<ActorWorkerContextProvider | ||
enabled={!data.destroyedAt} | ||
endpoint={data.endpoint} | ||
{...props} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: endpoint prop is passed before spreading ...props which could lead to endpoint being overridden if it exists in props
{!size?.includes("icon") && isLoading ? null : ( | ||
<Slottable>{children}</Slottable> | ||
)} | ||
{isIcon && isLoading ? null : <Slottable>{children}</Slottable>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This change may have introduced a regression. Previously, children were hidden for non-icon buttons during loading (!size?.includes('icon') && isLoading
). Now children are only hidden for icon buttons during loading (isIcon && isLoading
). This means non-icon buttons will show both the loading spinner and children simultaneously.
@@ -150,6 +150,12 @@ export class StateTooLarge extends ActorError { | |||
} | |||
} | |||
|
|||
export class Unsupported extends ActorError { | |||
constructor(feature: string) { | |||
super("unsupported", `Unsupported feature: ${feature}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: consider using backticks around feature name for consistency with other error messages like InvalidProtocolVersion
throw new errors.Unsupported("RPC"); | ||
} | ||
|
||
const { i: id, n: name, a: args = [] } = message.body.rr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: No validation on RPC name or args array length. Could lead to security issues if malicious input is provided.
throw new errors.Unsupported("Subscriptions"); | ||
} | ||
|
||
const { e: eventName, s: subscribe } = message.body.sr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: No validation on eventName - should check for empty string or invalid characters that could cause issues.
rpcRequestId = id; | ||
|
||
const ctx = new Rpc<A>(conn); | ||
const output = await handlers.onExecuteRpc(ctx, name, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: No timeout handling for RPC execution. Long-running RPCs could block the event loop.
if (error instanceof errors.ActorError && error.public) { | ||
code = error.code; | ||
message = String(error); | ||
metadata = error.metadata; | ||
} else { | ||
code = errors.INTERNAL_ERROR_CODE; | ||
message = errors.INTERNAL_ERROR_DESCRIPTION; | ||
internal = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Error handling could leak sensitive information if error.public is true but error.metadata contains sensitive data.
Merge activity
|
<!-- Please make sure there is an issue that this PR is correlated to. --> Closes ACTR-32 ## Discussion points - [ ] Current implementation vs. an additional layer of abstraction `Actor > { ActorUser, ActorInspect )` <!-- If there are frontend changes, please include screenshots. -->
Closes ACTR-32
Discussion points
Actor > { ActorUser, ActorInspect )