Skip to content

Commit 1cae221

Browse files
committed
fix(client): flatten skipReadyWait option
1 parent 94cdc35 commit 1cae221

9 files changed

Lines changed: 25 additions & 40 deletions

File tree

examples/kitchen-sink/scripts/mock-agentic-loop.ts

Lines changed: 4 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rivetkit-typescript/packages/rivetkit/src/client/actor-common.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,15 @@ export function resolveActorGatewayOptions(
5555
};
5656
}
5757

58-
export interface ActorActionOptions {
59-
gateway?: ActorGatewayOptions;
58+
export interface ActorActionOptions extends ActorGatewayOptions {
6059
signal?: AbortSignal;
6160
}
6261

63-
export interface ActorConnectOptions {
64-
gateway?: ActorGatewayOptions;
65-
}
62+
export type ActorConnectOptions = ActorGatewayOptions;
6663

67-
export interface ActorFetchInit extends RequestInit {
68-
gateway?: ActorGatewayOptions;
69-
}
64+
export type ActorFetchInit = RequestInit & ActorGatewayOptions;
7065

71-
export interface ActorWebSocketOptions {
72-
gateway?: ActorGatewayOptions;
73-
}
66+
export type ActorWebSocketOptions = ActorGatewayOptions;
7467

7568
/**
7669
* Maps action methods from actor definition to typed function signatures.

rivetkit-typescript/packages/rivetkit/src/client/actor-handle.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ export class ActorHandleRaw {
264264
let useQueryTarget = false;
265265
const gatewayOptions = resolveActorGatewayOptions(
266266
this.#gatewayOptions,
267-
opts.gateway,
267+
opts,
268268
);
269269

270270
for (let attempt = 0; attempt < maxAttempts; attempt++) {
@@ -586,7 +586,7 @@ export class ActorHandleRaw {
586586
getParams,
587587
this.#encoding,
588588
this.#actorResolutionState,
589-
resolveActorGatewayOptions(this.#gatewayOptions, options.gateway),
589+
resolveActorGatewayOptions(this.#gatewayOptions, options),
590590
);
591591

592592
return this.#client[CREATE_ACTOR_CONN_PROXY](
@@ -608,10 +608,10 @@ export class ActorHandleRaw {
608608
) {
609609
const maxAttempts = this.#getDynamicQueryMaxAttempts();
610610
let useQueryTarget = false;
611-
const { gateway, ...requestInit } = init ?? {};
611+
const { bypassConnectable, skipReadyWait, ...requestInit } = init ?? {};
612612
const gatewayOptions = resolveActorGatewayOptions(
613613
this.#gatewayOptions,
614-
gateway,
614+
{ bypassConnectable, skipReadyWait },
615615
);
616616

617617
for (let attempt = 0; attempt < maxAttempts; attempt++) {
@@ -820,7 +820,7 @@ export class ActorHandleRaw {
820820
const params = await this.#resolveConnectionParams();
821821
const gatewayOptions = resolveActorGatewayOptions(
822822
this.#gatewayOptions,
823-
options.gateway,
823+
options,
824824
);
825825
const target = gatewayOptions.bypassConnectable
826826
? await this.#resolveActionTarget(false)

rivetkit-typescript/packages/rivetkit/tests/driver/gateway-bypass-client.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describeDriverMatrix("Gateway Bypass Client", (driverTestConfig) => {
2828
await enabledTracking.action({
2929
name: "ping",
3030
args: [],
31-
gateway: { bypassConnectable: true },
31+
bypassConnectable: true,
3232
});
3333

3434
const enabledInfo = await enabledView.getRequestInfo();
@@ -47,7 +47,7 @@ describeDriverMatrix("Gateway Bypass Client", (driverTestConfig) => {
4747
await disabledTracking.action({
4848
name: "ping",
4949
args: [],
50-
gateway: { bypassConnectable: false },
50+
bypassConnectable: false,
5151
});
5252

5353
const disabledInfo = await disabledView.getRequestInfo();
@@ -87,7 +87,7 @@ describeDriverMatrix("Gateway Bypass Client", (driverTestConfig) => {
8787
await overrideTracking.action({
8888
name: "ping",
8989
args: [],
90-
gateway: { bypassConnectable: false },
90+
bypassConnectable: false,
9191
});
9292

9393
const overrideInfo = await overrideView.getRequestInfo();
@@ -116,7 +116,7 @@ describeDriverMatrix("Gateway Bypass Client", (driverTestConfig) => {
116116
params: { trackRequest: true },
117117
})
118118
.connect(undefined, {
119-
gateway: { bypassConnectable: true },
119+
bypassConnectable: true,
120120
});
121121

122122
const bypassInfo = await bypassConn.getRequestInfo();
@@ -148,7 +148,7 @@ describeDriverMatrix("Gateway Bypass Client", (driverTestConfig) => {
148148
params: { trackRequest: true },
149149
})
150150
.connect(undefined, {
151-
gateway: { bypassConnectable: false },
151+
bypassConnectable: false,
152152
});
153153

154154
const overrideInfo = await overrideConn.getRequestInfo();

rivetkit-typescript/packages/rivetkit/tests/remote-engine-client-public-token.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe.sequential("RemoteEngineControlClient public token usage", () => {
134134
const handle = client.getForId("mockAgenticLoop", "actor-http-bypass");
135135

136136
const response = await handle.fetch("/bypass", {
137-
gateway: { bypassConnectable: true },
137+
bypassConnectable: true,
138138
});
139139

140140
expect(response.status).toBe(200);

website/src/content/docs/actors/lifecycle.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ curl -X POST \
763763

764764
### Skip Ready Wait
765765

766-
The gateway normally holds requests until the actor is ready. The actor is not ready during startup (before `onWake` finishes) or during the sleep grace period (while `onSleep` and `waitUntil` are running). Probes and readiness checks can opt out with `gateway.skipReadyWait` to reach the actor's `onRequest` or `onWebSocket` handler in either window.
766+
The gateway normally holds requests until the actor is ready. The actor is not ready during startup (before `onWake` finishes) or during the sleep grace period (while `onSleep` and `waitUntil` are running). Probes and readiness checks can opt out with `skipReadyWait` to reach the actor's `onRequest` or `onWebSocket` handler in either window.
767767

768768
See [Skip Ready Wait](/docs/clients/javascript#skip-ready-wait) on the JavaScript client page for usage.
769769

website/src/content/docs/actors/request-handler.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ The `onRequest` handler is WinterTC compliant and will work with existing librar
253253

254254
### Skip Ready Wait
255255

256-
Requests are normally held at the gateway until the actor is ready. Pass `gateway.skipReadyWait: true` on `handle.fetch()` to deliver immediately, including while the actor is still starting or in the [sleep grace period](/docs/actors/lifecycle#shutdown-sequence). See [Skip Ready Wait](/docs/clients/javascript#skip-ready-wait) for details.
256+
Requests are normally held at the gateway until the actor is ready. Pass `skipReadyWait: true` on `handle.fetch()` to deliver immediately, including while the actor is still starting or in the [sleep grace period](/docs/actors/lifecycle#shutdown-sequence). See [Skip Ready Wait](/docs/clients/javascript#skip-ready-wait) for details.
257257

258258
## API Reference
259259

website/src/content/docs/actors/websocket-handler.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const myActor = actor({
297297

298298
### Skip Ready Wait
299299

300-
Connections are normally held at the gateway until the actor is ready. Pass `gateway.skipReadyWait: true` on `handle.webSocket()` to connect immediately, including while the actor is still starting or in the [sleep grace period](/docs/actors/lifecycle#shutdown-sequence). See [Skip Ready Wait](/docs/clients/javascript#skip-ready-wait) for details.
300+
Connections are normally held at the gateway until the actor is ready. Pass `skipReadyWait: true` on `handle.webSocket()` to connect immediately, including while the actor is still starting or in the [sleep grace period](/docs/actors/lifecycle#shutdown-sequence). See [Skip Ready Wait](/docs/clients/javascript#skip-ready-wait) for details.
301301

302302
### Async Handlers
303303

website/src/content/docs/clients/javascript.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ You can also pass the endpoint without auth and provide `RIVET_NAMESPACE` and `R
259259

260260
Requests are normally held at the gateway until the actor is ready to accept traffic. An actor is not ready while it's still starting (before `onWake` finishes) or while it's in the [sleep grace period](/docs/actors/lifecycle#shutdown-sequence) (running `onSleep`, `waitUntil`, and pending disconnects).
261261

262-
Pass `gateway.skipReadyWait: true` on the [low-level HTTP and WebSocket APIs](#low-level-http--websocket) to deliver immediately and reach the actor's `onRequest` / `onWebSocket` handler in either window:
262+
Pass `skipReadyWait: true` on the [low-level HTTP and WebSocket APIs](#low-level-http--websocket) to deliver immediately and reach the actor's `onRequest` / `onWebSocket` handler in either window:
263263

264264
```ts @nocheck
265265
import { createClient } from "rivetkit/client";
@@ -268,11 +268,11 @@ const client = createClient();
268268
const handle = client.chatRoom.getOrCreate(["general"]);
269269

270270
const response = await handle.fetch("/healthz", {
271-
gateway: { skipReadyWait: true },
271+
skipReadyWait: true,
272272
});
273273

274274
const ws = await handle.webSocket("probe", undefined, {
275-
gateway: { skipReadyWait: true },
275+
skipReadyWait: true,
276276
});
277277
```
278278

0 commit comments

Comments
 (0)