Skip to content

Commit 2b9939b

Browse files
committed
chore(rivetkit): improve conn inspector properties
1 parent 20316f6 commit 2b9939b

File tree

1 file changed

+20
-1
lines changed
  • rivetkit-typescript/packages/rivetkit/src/actor

1 file changed

+20
-1
lines changed

rivetkit-typescript/packages/rivetkit/src/actor/instance.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
225225
return Array.from(this.#connections.entries()).map(
226226
([id, conn]) => ({
227227
id,
228-
stateEnabled: conn.__stateEnabled,
229228
params: conn.params as any,
230229
state: conn.__stateEnabled ? conn.state : undefined,
230+
status: conn.status,
231+
subscriptions: conn.subscriptions.size,
232+
lastSeen: conn.lastSeen,
233+
stateEnabled: conn.__stateEnabled,
234+
isHibernatable: conn.isHibernatable,
231235
}),
232236
);
233237
},
@@ -1291,13 +1295,19 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
12911295
#checkConnectionsLiveness() {
12921296
this.#rLog.debug({ msg: "checking connections liveness" });
12931297

1298+
let connected = 0;
1299+
let reconnecting = 0;
1300+
let removed = 0;
12941301
for (const conn of this.#connections.values()) {
12951302
if (conn.__status === "connected") {
1303+
connected += 1;
12961304
this.#rLog.debug({
12971305
msg: "connection is alive",
12981306
connId: conn.id,
12991307
});
13001308
} else {
1309+
reconnecting += 1;
1310+
13011311
const lastSeen = conn.__persist.lastSeen;
13021312
const sinceLastSeen = Date.now() - lastSeen;
13031313
if (
@@ -1321,9 +1331,18 @@ export class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
13211331
});
13221332

13231333
// Assume that the connection is dead here, no need to disconnect anything
1334+
removed += 1;
13241335
this.#removeConn(conn);
13251336
}
13261337
}
1338+
1339+
this.#rLog.debug({
1340+
msg: "checked connection liveness",
1341+
total: connected + reconnecting,
1342+
connected,
1343+
reconnecting,
1344+
removed,
1345+
});
13271346
}
13281347

13291348
/**

0 commit comments

Comments
 (0)