Skip to content

Commit 656743e

Browse files
committed
chore(rivetkit): doc skip ready wait
1 parent f7d89ed commit 656743e

11 files changed

Lines changed: 52 additions & 11 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type ActorActionFunction<
3232
) => Promise<Response>;
3333

3434
export interface ActorGatewayOptions {
35-
bypassConnectable?: boolean;
35+
skipReadyWait?: boolean;
3636
}
3737

3838
export interface ActorFetchInit extends RequestInit {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ export class ActorHandleRaw {
793793
options: ActorWebSocketOptions = {},
794794
) {
795795
const params = await this.#resolveConnectionParams();
796-
const target = options.gateway?.bypassConnectable
796+
const target = options.gateway?.skipReadyWait
797797
? await this.#resolveActionTarget(false)
798798
: getGatewayTarget(this.#actorResolutionState);
799799
return await rawWebSocket(

rivetkit-typescript/packages/rivetkit/src/engine-client/actor-http-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function buildGuardHeaders(
7979
headers.set(HEADER_RIVET_TARGET, "actor");
8080
headers.set(HEADER_RIVET_ACTOR, options.directActorId);
8181
}
82-
if (options.bypassConnectable) {
82+
if (options.skipReadyWait) {
8383
headers.set(HEADER_RIVET_BYPASS_CONNECTABLE, "1");
8484
}
8585
return headers;

rivetkit-typescript/packages/rivetkit/src/engine-client/actor-websocket-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export function buildActorQueryGatewayUrl(
269269
if (token !== undefined) {
270270
params.append("rvt-token", token);
271271
}
272-
if (options.bypassConnectable) {
272+
if (options.skipReadyWait) {
273273
params.append("rvt-bypass_connectable", "true");
274274
}
275275

@@ -392,7 +392,7 @@ export function buildWebSocketProtocols(
392392
protocols.push(`${WS_PROTOCOL_TARGET}${target.target}`);
393393
protocols.push(`${WS_PROTOCOL_ACTOR}${target.actorId}`);
394394
}
395-
if (options.bypassConnectable) {
395+
if (options.skipReadyWait) {
396396
protocols.push(WS_PROTOCOL_BYPASS_CONNECTABLE);
397397
}
398398
if (params) {

rivetkit-typescript/packages/rivetkit/src/engine-client/driver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { ActorQuery, CrashPolicy } from "@/client/query";
77
export type GatewayTarget = { directId: string } | ActorQuery;
88

99
export interface GatewayRequestOptions {
10-
bypassConnectable?: boolean;
10+
skipReadyWait?: boolean;
1111
}
1212

1313
export interface EngineControlClient {

rivetkit-typescript/packages/rivetkit/src/engine-client/mod.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export class RemoteEngineControlClient implements EngineControlClient {
255255
const gatewayUrl = this.#buildGatewayUrlForTarget(target, path, options);
256256
const httpOptions = {
257257
...options,
258-
directActorId: options.bypassConnectable
258+
directActorId: options.skipReadyWait
259259
? directActorIdFromTarget(target)
260260
: undefined,
261261
};
@@ -286,7 +286,7 @@ export class RemoteEngineControlClient implements EngineControlClient {
286286
params,
287287
{
288288
...options,
289-
directActorId: options.bypassConnectable
289+
directActorId: options.skipReadyWait
290290
? directActorIdFromTarget(target)
291291
: undefined,
292292
},
@@ -410,7 +410,7 @@ export class RemoteEngineControlClient implements EngineControlClient {
410410
): string {
411411
const endpoint = getEndpoint(this.#config);
412412

413-
if (options.bypassConnectable && directActorIdFromTarget(target)) {
413+
if (options.skipReadyWait && directActorIdFromTarget(target)) {
414414
return combineUrlPath(endpoint, path);
415415
}
416416

rivetkit-typescript/packages/rivetkit/tests/actor-gateway-url.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe("gateway URL builders", () => {
5656
expect(url).not.toContain("@");
5757
});
5858

59-
test("serializes gateway bypass for query routing", () => {
59+
test("serializes skipReadyWait for query routing", () => {
6060
const url = buildActorQueryGatewayUrl(
6161
"https://api.rivet.dev/manager",
6262
"prod",
@@ -71,7 +71,7 @@ describe("gateway URL builders", () => {
7171
undefined,
7272
undefined,
7373
undefined,
74-
{ bypassConnectable: true },
74+
{ skipReadyWait: true },
7575
);
7676

7777
expect(new URL(url).searchParams.get("rvt-bypass_connectable")).toBe(

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,12 @@ curl -X POST \
761761

762762
`/sleep` asks the actor to enter the normal sleep shutdown sequence. `/reschedule` asks the platform to allocate the actor again, which is useful after crashes or when you need to force a fresh placement. Both endpoints require the actor ID and namespace.
763763

764+
### Skip Ready Wait
765+
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.
767+
768+
See [Skip Ready Wait](/docs/clients/javascript#skip-ready-wait) on the JavaScript client page for usage.
769+
764770
### Keeping the Actor Awake
765771

766772
RivetKit gives you two primitives for holding the actor awake across background work. Both take a `Promise` and differ in how they interact with idle sleep and the grace period.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ The `onRequest` handler is WinterTC compliant and will work with existing librar
249249
- Does not support streaming responses & server-sent events at the moment. See the [tracking issue](https://github.com/rivet-dev/rivet/issues/3529).
250250
- `OPTIONS` requests currently are handled by Rivet and are not passed to `onRequest`
251251

252+
## Advanced
253+
254+
### Skip Ready Wait
255+
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.
257+
252258
## API Reference
253259

254260
- [`RequestContext`](/typedoc/interfaces/rivetkit.mod.RequestContext.html) - Context for HTTP request handlers

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ const myActor = actor({
295295
});
296296
```
297297

298+
### Skip Ready Wait
299+
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.
301+
298302
### Async Handlers
299303

300304
The `onWebSocket` handler can be async, allowing you to perform async code before setting up event listeners:

0 commit comments

Comments
 (0)