@rivetkit/engine-runner 2.1.9 → 2.1.10
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/mod.cjs +26 -2
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.ts +17 -0
- package/dist/mod.js +25 -1
- package/dist/mod.js.map +1 -1
- package/package.json +3 -3
- package/src/actor.ts +7 -0
- package/src/mod.ts +23 -1
package/dist/mod.cjs
CHANGED
|
@@ -104,7 +104,7 @@ ${error.stack}` : ""}`;
|
|
|
104
104
|
|
|
105
105
|
// src/actor.ts
|
|
106
106
|
var RunnerActor = (_class = class {
|
|
107
|
-
constructor(actorId, generation, config, hibernatingRequests) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);
|
|
107
|
+
constructor(actorId, generation, config, hibernatingRequests) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);
|
|
108
108
|
this.hibernatingRequests = hibernatingRequests;
|
|
109
109
|
this.actorId = actorId;
|
|
110
110
|
this.generation = generation;
|
|
@@ -125,6 +125,12 @@ var RunnerActor = (_class = class {
|
|
|
125
125
|
* that the caller is implemented correctly.
|
|
126
126
|
**/
|
|
127
127
|
__init6() {this.hibernationRestored = false}
|
|
128
|
+
/**
|
|
129
|
+
* Set when the actor has explicitly requested to stop (e.g. c.destroy()).
|
|
130
|
+
* Used to send StopCode.Ok (graceful) vs StopCode.Error (ungraceful) so
|
|
131
|
+
* the engine crash policy handles sleepable actors correctly.
|
|
132
|
+
**/
|
|
133
|
+
__init7() {this.stopIntentSent = false}
|
|
128
134
|
// Pending request methods
|
|
129
135
|
getPendingRequest(gatewayId, requestId) {
|
|
130
136
|
var _a;
|
|
@@ -1534,6 +1540,7 @@ var Runner = class {
|
|
|
1534
1540
|
|
|
1535
1541
|
#started = false;
|
|
1536
1542
|
#shutdown = false;
|
|
1543
|
+
#draining = false;
|
|
1537
1544
|
#reconnectAttempt = 0;
|
|
1538
1545
|
#reconnectTimeout;
|
|
1539
1546
|
// Protocol metadata
|
|
@@ -1593,6 +1600,22 @@ var Runner = class {
|
|
|
1593
1600
|
if (!actor) return;
|
|
1594
1601
|
this.#sendActorIntent(actorId, actor.generation, "stop");
|
|
1595
1602
|
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Like stopActor but marks the actor for graceful destruction.
|
|
1605
|
+
* This ensures the engine destroys the actor instead of sleeping it.
|
|
1606
|
+
*
|
|
1607
|
+
* NOTE: If a drain (GoingAway) occurs after this is called but before the
|
|
1608
|
+
* stop completes, the engine's going_away flag overrides graceful_exit and
|
|
1609
|
+
* the actor will sleep instead of being destroyed. The destroy intent is
|
|
1610
|
+
* lost in this race. This is acceptable since the actor will be rescheduled
|
|
1611
|
+
* elsewhere and can be destroyed on the next wake.
|
|
1612
|
+
*/
|
|
1613
|
+
destroyActor(actorId, generation) {
|
|
1614
|
+
const actor = this.getActor(actorId, generation);
|
|
1615
|
+
if (!actor) return;
|
|
1616
|
+
actor.stopIntentSent = true;
|
|
1617
|
+
this.#sendActorIntent(actorId, actor.generation, "stop");
|
|
1618
|
+
}
|
|
1596
1619
|
async forceStopActor(actorId, generation) {
|
|
1597
1620
|
var _a, _b;
|
|
1598
1621
|
(_a = this.log) == null ? void 0 : _a.debug({
|
|
@@ -1745,6 +1768,7 @@ var Runner = class {
|
|
|
1745
1768
|
return;
|
|
1746
1769
|
}
|
|
1747
1770
|
this.#shutdown = true;
|
|
1771
|
+
this.#draining = !immediate;
|
|
1748
1772
|
(_b = this.log) == null ? void 0 : _b.info({
|
|
1749
1773
|
msg: "starting shutdown",
|
|
1750
1774
|
immediate,
|
|
@@ -2319,7 +2343,7 @@ var Runner = class {
|
|
|
2319
2343
|
actorState = {
|
|
2320
2344
|
tag: "ActorStateStopped",
|
|
2321
2345
|
val: {
|
|
2322
|
-
code: protocol.StopCode.Ok,
|
|
2346
|
+
code: actor.stopIntentSent || this.#draining ? protocol.StopCode.Ok : protocol.StopCode.Error,
|
|
2323
2347
|
message: null
|
|
2324
2348
|
}
|
|
2325
2349
|
};
|