rivetkit 3.0.0-preview.3 → 3.0.0-preview.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client.js +49 -28
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-KCWRKXTY.js → chunk-AW7C2XT5.js} +2 -2
- package/dist/tsup/{chunk-JWI6YJEA.js → chunk-BAXQGOBL.js} +2 -2
- package/dist/tsup/{chunk-4WDX5ZI7.cjs → chunk-CFGRIV62.cjs} +2 -2
- package/dist/tsup/{chunk-4WDX5ZI7.cjs.map → chunk-CFGRIV62.cjs.map} +1 -1
- package/dist/tsup/{chunk-7KES6QNE.cjs → chunk-CLY73DEM.cjs} +3 -3
- package/dist/tsup/{chunk-7KES6QNE.cjs.map → chunk-CLY73DEM.cjs.map} +1 -1
- package/dist/tsup/{chunk-KMYBA4P5.cjs → chunk-EON5X6B7.cjs} +3 -3
- package/dist/tsup/{chunk-KMYBA4P5.cjs.map → chunk-EON5X6B7.cjs.map} +1 -1
- package/dist/tsup/{chunk-2VXPVVNW.js → chunk-EOUH7MP7.js} +54 -33
- package/dist/tsup/chunk-EOUH7MP7.js.map +1 -0
- package/dist/tsup/{chunk-BCX5V7NI.cjs → chunk-GJUWI47D.cjs} +191 -170
- package/dist/tsup/chunk-GJUWI47D.cjs.map +1 -0
- package/dist/tsup/{chunk-PJ4PORWE.cjs → chunk-KEHBPXZE.cjs} +3 -3
- package/dist/tsup/{chunk-PJ4PORWE.cjs.map → chunk-KEHBPXZE.cjs.map} +1 -1
- package/dist/tsup/{chunk-HDQQVBOG.js → chunk-KJM23DKG.js} +2 -2
- package/dist/tsup/{chunk-JXO5QVDX.js → chunk-KKSIGBUN.js} +2 -2
- package/dist/tsup/{chunk-JXO5QVDX.js.map → chunk-KKSIGBUN.js.map} +1 -1
- package/dist/tsup/{chunk-HRBZ4VW5.cjs → chunk-MVDTFTCY.cjs} +7 -7
- package/dist/tsup/{chunk-HRBZ4VW5.cjs.map → chunk-MVDTFTCY.cjs.map} +1 -1
- package/dist/tsup/{chunk-B6U5V6WE.cjs → chunk-PHFXQQGE.cjs} +4 -4
- package/dist/tsup/{chunk-B6U5V6WE.cjs.map → chunk-PHFXQQGE.cjs.map} +1 -1
- package/dist/tsup/{chunk-A447S5YG.js → chunk-SJUGJ5DT.js} +2 -2
- package/dist/tsup/{chunk-AGQNNAZ2.js → chunk-W4CGRSYM.js} +3 -3
- package/dist/tsup/{chunk-IJGFSNGA.js → chunk-W5DDGJBO.js} +4 -4
- package/dist/tsup/{chunk-7Y4GHUAT.cjs → chunk-ZOFNA4SR.cjs} +10 -10
- package/dist/tsup/{chunk-7Y4GHUAT.cjs.map → chunk-ZOFNA4SR.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.js +3 -3
- package/dist/tsup/mod.cjs +94 -90
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.js +15 -11
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +7 -7
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +9 -9
- package/src/client/actor-conn.ts +59 -33
- package/src/client/lifecycle-errors.ts +13 -0
- package/src/registry/config/index.ts +2 -1
- package/src/registry/index.ts +16 -3
- package/dist/tsup/chunk-2VXPVVNW.js.map +0 -1
- package/dist/tsup/chunk-BCX5V7NI.cjs.map +0 -1
- /package/dist/tsup/{chunk-KCWRKXTY.js.map → chunk-AW7C2XT5.js.map} +0 -0
- /package/dist/tsup/{chunk-JWI6YJEA.js.map → chunk-BAXQGOBL.js.map} +0 -0
- /package/dist/tsup/{chunk-HDQQVBOG.js.map → chunk-KJM23DKG.js.map} +0 -0
- /package/dist/tsup/{chunk-A447S5YG.js.map → chunk-SJUGJ5DT.js.map} +0 -0
- /package/dist/tsup/{chunk-AGQNNAZ2.js.map → chunk-W4CGRSYM.js.map} +0 -0
- /package/dist/tsup/{chunk-IJGFSNGA.js.map → chunk-W5DDGJBO.js.map} +0 -0
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
deserializeActorKey,
|
|
4
4
|
serializeActorKey
|
|
5
5
|
} from "./chunk-A2CF6PFH.js";
|
|
6
|
-
import {
|
|
7
|
-
importWebSocket,
|
|
8
|
-
logger
|
|
9
|
-
} from "./chunk-A447S5YG.js";
|
|
10
6
|
import {
|
|
11
7
|
AsyncMutex
|
|
12
8
|
} from "./chunk-JTHHCZCZ.js";
|
|
9
|
+
import {
|
|
10
|
+
importWebSocket,
|
|
11
|
+
logger
|
|
12
|
+
} from "./chunk-SJUGJ5DT.js";
|
|
13
13
|
import {
|
|
14
14
|
EncodingSchema,
|
|
15
15
|
assertUnreachable,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
serializeWithEncoding,
|
|
37
37
|
stringifyError,
|
|
38
38
|
uint8ArrayToBase64
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-KKSIGBUN.js";
|
|
40
40
|
import {
|
|
41
41
|
INTERNAL_ERROR_CODE,
|
|
42
42
|
RivetError,
|
|
@@ -2266,6 +2266,14 @@ function classifyActorError(error) {
|
|
|
2266
2266
|
}
|
|
2267
2267
|
);
|
|
2268
2268
|
}
|
|
2269
|
+
if (error.group === "ups" && error.code === "consumer_closed" || error.group === "depot" && error.code === "request_deadline_exceeded") {
|
|
2270
|
+
return buildLifecycleBoundaryInfo(
|
|
2271
|
+
"reconnect_only",
|
|
2272
|
+
"actor_error",
|
|
2273
|
+
error.message,
|
|
2274
|
+
{ group: error.group, code: error.code }
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2269
2277
|
if (error.group === "guard" && isRetryableGuardGatewayHttpError(error.code)) {
|
|
2270
2278
|
return buildLifecycleBoundaryInfo(
|
|
2271
2279
|
"request_retry",
|
|
@@ -4020,6 +4028,8 @@ var ActorConnRaw = class {
|
|
|
4020
4028
|
/* Will be aborted on dispose. */
|
|
4021
4029
|
#abortController = new AbortController();
|
|
4022
4030
|
#connStatus = "idle";
|
|
4031
|
+
/** The opening failure that stopped retries. Later actions must fail instead of queueing. */
|
|
4032
|
+
#connectionOpenError;
|
|
4023
4033
|
#actorId;
|
|
4024
4034
|
#connId;
|
|
4025
4035
|
#messageQueue = [];
|
|
@@ -4141,6 +4151,8 @@ var ActorConnRaw = class {
|
|
|
4141
4151
|
`Invalid action call: expected an options object { name, args }, got ${typeof opts}. Use conn.actionName(...args) for the shorthand API.`
|
|
4142
4152
|
);
|
|
4143
4153
|
}
|
|
4154
|
+
if (this.#disposed) throw new ActorConnDisposed();
|
|
4155
|
+
if (this.#connectionOpenError) throw this.#connectionOpenError;
|
|
4144
4156
|
logger().debug({ msg: "action", name: opts.name, args: opts.args });
|
|
4145
4157
|
const actionId = this.#actionIdCounter;
|
|
4146
4158
|
this.#actionIdCounter += 1;
|
|
@@ -4228,6 +4240,7 @@ var ActorConnRaw = class {
|
|
|
4228
4240
|
}
|
|
4229
4241
|
}
|
|
4230
4242
|
#connectWithRetry() {
|
|
4243
|
+
this.#connectionOpenError = void 0;
|
|
4231
4244
|
this.#setConnStatus("connecting");
|
|
4232
4245
|
pRetry(this.#connectAndWait.bind(this), {
|
|
4233
4246
|
forever: true,
|
|
@@ -4270,6 +4283,9 @@ var ActorConnRaw = class {
|
|
|
4270
4283
|
await this.#connectWebSocket();
|
|
4271
4284
|
await this.#waitForOpen(this.#onOpenPromise.promise);
|
|
4272
4285
|
} catch (error) {
|
|
4286
|
+
this.#abandonCurrentSocket(
|
|
4287
|
+
isConnectionOpenTimeout(error) ? "Connect timeout" : "Connection opening failed"
|
|
4288
|
+
);
|
|
4273
4289
|
if (this.#shouldRetryConnectionOpenError(error)) {
|
|
4274
4290
|
throw error;
|
|
4275
4291
|
}
|
|
@@ -4279,7 +4295,7 @@ var ActorConnRaw = class {
|
|
|
4279
4295
|
`Failed to open connection: ${stringifyError(error)}`,
|
|
4280
4296
|
{ error: stringifyError(error) }
|
|
4281
4297
|
);
|
|
4282
|
-
this.#
|
|
4298
|
+
this.#connectionOpenError = actorError;
|
|
4283
4299
|
this.#rejectPendingPromises(actorError, false);
|
|
4284
4300
|
this.#dispatchActorError(actorError);
|
|
4285
4301
|
this.#setConnStatus("idle");
|
|
@@ -4311,28 +4327,23 @@ var ActorConnRaw = class {
|
|
|
4311
4327
|
});
|
|
4312
4328
|
try {
|
|
4313
4329
|
await Promise.race([open, timedOut]);
|
|
4314
|
-
} catch (error) {
|
|
4315
|
-
if (isConnectionOpenTimeout(error)) {
|
|
4316
|
-
this.#abandonCurrentSocket();
|
|
4317
|
-
}
|
|
4318
|
-
throw error;
|
|
4319
4330
|
} finally {
|
|
4320
4331
|
clearTimeout(timer);
|
|
4321
4332
|
}
|
|
4322
4333
|
}
|
|
4323
|
-
#abandonCurrentSocket() {
|
|
4334
|
+
#abandonCurrentSocket(reason) {
|
|
4324
4335
|
const ws = this.#websocket;
|
|
4325
4336
|
if (!ws) return;
|
|
4326
4337
|
this.#websocket = void 0;
|
|
4327
4338
|
this.#abandonedSockets.add(ws);
|
|
4328
|
-
logger().
|
|
4329
|
-
msg: "
|
|
4339
|
+
logger().debug({
|
|
4340
|
+
msg: "closing failed connection attempt",
|
|
4330
4341
|
connId: this.#connId,
|
|
4331
4342
|
readyState: ws.readyState,
|
|
4332
|
-
|
|
4343
|
+
reason
|
|
4333
4344
|
});
|
|
4334
4345
|
try {
|
|
4335
|
-
ws.close(1e3,
|
|
4346
|
+
ws.close(1e3, reason);
|
|
4336
4347
|
} catch (err) {
|
|
4337
4348
|
logger().debug({
|
|
4338
4349
|
msg: "failed to close abandoned websocket",
|
|
@@ -4347,6 +4358,9 @@ var ActorConnRaw = class {
|
|
|
4347
4358
|
if (isConnectionOpenTimeout(error)) {
|
|
4348
4359
|
return true;
|
|
4349
4360
|
}
|
|
4361
|
+
if (error instanceof RivetError && error.group === "client" && error.code === "connection_open_interrupted") {
|
|
4362
|
+
return true;
|
|
4363
|
+
}
|
|
4350
4364
|
if (error instanceof RivetError && isInvalidToken(error.group, error.code) && this.#driver.refreshAuthToken && this.#authRetryAvailable) {
|
|
4351
4365
|
this.#authRetryAvailable = false;
|
|
4352
4366
|
return true;
|
|
@@ -4406,16 +4420,18 @@ var ActorConnRaw = class {
|
|
|
4406
4420
|
});
|
|
4407
4421
|
this.#websocket = ws;
|
|
4408
4422
|
ws.addEventListener("open", () => {
|
|
4409
|
-
if (this.#abandonedSockets.has(ws))
|
|
4423
|
+
if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
|
|
4424
|
+
return;
|
|
4410
4425
|
logger().debug({
|
|
4411
4426
|
msg: "client websocket open",
|
|
4412
4427
|
connId: this.#connId
|
|
4413
4428
|
});
|
|
4414
4429
|
});
|
|
4415
4430
|
ws.addEventListener("message", async (ev) => {
|
|
4416
|
-
if (this.#abandonedSockets.has(ws))
|
|
4431
|
+
if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
|
|
4432
|
+
return;
|
|
4417
4433
|
try {
|
|
4418
|
-
await this.#handleOnMessage(ev.data);
|
|
4434
|
+
await this.#handleOnMessage(ev.data, ws);
|
|
4419
4435
|
} catch (err) {
|
|
4420
4436
|
logger().error({
|
|
4421
4437
|
msg: "error in websocket message handler",
|
|
@@ -4424,7 +4440,8 @@ var ActorConnRaw = class {
|
|
|
4424
4440
|
}
|
|
4425
4441
|
});
|
|
4426
4442
|
ws.addEventListener("close", async (ev) => {
|
|
4427
|
-
if (this.#abandonedSockets.has(ws))
|
|
4443
|
+
if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
|
|
4444
|
+
return;
|
|
4428
4445
|
try {
|
|
4429
4446
|
await this.#handleOnClose(ev);
|
|
4430
4447
|
} catch (err) {
|
|
@@ -4435,7 +4452,8 @@ var ActorConnRaw = class {
|
|
|
4435
4452
|
}
|
|
4436
4453
|
});
|
|
4437
4454
|
ws.addEventListener("error", () => {
|
|
4438
|
-
if (this.#abandonedSockets.has(ws))
|
|
4455
|
+
if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
|
|
4456
|
+
return;
|
|
4439
4457
|
try {
|
|
4440
4458
|
this.#handleOnError();
|
|
4441
4459
|
} catch (err) {
|
|
@@ -4501,7 +4519,7 @@ var ActorConnRaw = class {
|
|
|
4501
4519
|
});
|
|
4502
4520
|
}
|
|
4503
4521
|
/** Called by the onmessage event from drivers. */
|
|
4504
|
-
async #handleOnMessage(data) {
|
|
4522
|
+
async #handleOnMessage(data, socket) {
|
|
4505
4523
|
var _a;
|
|
4506
4524
|
logger().trace({
|
|
4507
4525
|
msg: "received message",
|
|
@@ -4510,6 +4528,8 @@ var ActorConnRaw = class {
|
|
|
4510
4528
|
isArrayBuffer: data instanceof ArrayBuffer
|
|
4511
4529
|
});
|
|
4512
4530
|
const response = await this.#parseMessage(data);
|
|
4531
|
+
if (this.#websocket !== socket || this.#abandonedSockets.has(socket))
|
|
4532
|
+
return;
|
|
4513
4533
|
logger().trace(
|
|
4514
4534
|
getLogMessage() ? {
|
|
4515
4535
|
msg: "parsed message",
|
|
@@ -4581,18 +4601,15 @@ var ActorConnRaw = class {
|
|
|
4581
4601
|
this.#actorResolutionState,
|
|
4582
4602
|
this.#driver
|
|
4583
4603
|
);
|
|
4604
|
+
if (this.#websocket !== socket || this.#abandonedSockets.has(socket)) {
|
|
4605
|
+
return;
|
|
4606
|
+
}
|
|
4584
4607
|
if (schedulingError) {
|
|
4585
4608
|
errorToThrow = schedulingError;
|
|
4586
4609
|
}
|
|
4587
4610
|
}
|
|
4588
|
-
if (this.#onOpenPromise) {
|
|
4589
|
-
this.#onOpenPromise.reject(errorToThrow);
|
|
4590
|
-
}
|
|
4591
4611
|
this.#invalidateActorIfStale(group, code);
|
|
4592
|
-
|
|
4593
|
-
inFlight.reject(errorToThrow);
|
|
4594
|
-
this.#actionsInFlight.delete(id);
|
|
4595
|
-
}
|
|
4612
|
+
this.#rejectPendingPromises(errorToThrow, false);
|
|
4596
4613
|
this.#dispatchActorError(errorToThrow);
|
|
4597
4614
|
}
|
|
4598
4615
|
} else if (response.body.tag === "ActionResponse") {
|
|
@@ -4702,9 +4719,12 @@ var ActorConnRaw = class {
|
|
|
4702
4719
|
}
|
|
4703
4720
|
this.#invalidateActorIfStale(group, code);
|
|
4704
4721
|
} else {
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4722
|
+
const message = `${wasClean ? "Connection closed" : "Connection lost"} (code: ${closeEvent.code}, reason: ${reason})`;
|
|
4723
|
+
error = !wasConnected && closeEvent.code === 1006 ? new RivetError(
|
|
4724
|
+
"client",
|
|
4725
|
+
"connection_open_interrupted",
|
|
4726
|
+
message
|
|
4727
|
+
) : new Error(message);
|
|
4708
4728
|
}
|
|
4709
4729
|
this.#rejectPendingPromises(error, false);
|
|
4710
4730
|
if (error instanceof RivetError) {
|
|
@@ -4720,6 +4740,7 @@ var ActorConnRaw = class {
|
|
|
4720
4740
|
}
|
|
4721
4741
|
}
|
|
4722
4742
|
#rejectPendingPromises(error, suppressUnhandled) {
|
|
4743
|
+
this.#clearQueuedMessages();
|
|
4723
4744
|
if (this.#onOpenPromise) {
|
|
4724
4745
|
if (suppressUnhandled) {
|
|
4725
4746
|
this.#onOpenPromise.promise.catch(() => {
|
|
@@ -6529,4 +6550,4 @@ export {
|
|
|
6529
6550
|
updateRunnerConfig,
|
|
6530
6551
|
RemoteEngineControlClient
|
|
6531
6552
|
};
|
|
6532
|
-
//# sourceMappingURL=chunk-
|
|
6553
|
+
//# sourceMappingURL=chunk-EOUH7MP7.js.map
|