@rivetkit/engine-runner 2.0.37 → 2.0.39
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 +19 -22
- package/dist/mod.cjs.map +1 -1
- package/dist/mod.js +19 -22
- package/dist/mod.js.map +1 -1
- package/package.json +2 -2
- package/src/mod.ts +23 -28
package/dist/mod.js
CHANGED
|
@@ -1516,7 +1516,6 @@ var Runner = class {
|
|
|
1516
1516
|
runnerId;
|
|
1517
1517
|
#started = false;
|
|
1518
1518
|
#shutdown = false;
|
|
1519
|
-
#shuttingDown = false;
|
|
1520
1519
|
#reconnectAttempt = 0;
|
|
1521
1520
|
#reconnectTimeout;
|
|
1522
1521
|
// Runner lost threshold management
|
|
@@ -1720,19 +1719,18 @@ var Runner = class {
|
|
|
1720
1719
|
// MARK: Shutdown
|
|
1721
1720
|
async shutdown(immediate, exit = false) {
|
|
1722
1721
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1723
|
-
if (this.#
|
|
1722
|
+
if (this.#shutdown) {
|
|
1724
1723
|
(_a = this.log) == null ? void 0 : _a.debug({
|
|
1725
1724
|
msg: "shutdown already in progress, ignoring"
|
|
1726
1725
|
});
|
|
1727
1726
|
return;
|
|
1728
1727
|
}
|
|
1729
|
-
this.#
|
|
1728
|
+
this.#shutdown = true;
|
|
1730
1729
|
(_b = this.log) == null ? void 0 : _b.info({
|
|
1731
1730
|
msg: "starting shutdown",
|
|
1732
1731
|
immediate,
|
|
1733
1732
|
exit
|
|
1734
1733
|
});
|
|
1735
|
-
this.#shutdown = true;
|
|
1736
1734
|
if (this.#reconnectTimeout) {
|
|
1737
1735
|
clearTimeout(this.#reconnectTimeout);
|
|
1738
1736
|
this.#reconnectTimeout = void 0;
|
|
@@ -2049,7 +2047,7 @@ var Runner = class {
|
|
|
2049
2047
|
ws.addEventListener("error", (ev) => {
|
|
2050
2048
|
var _a2, _b2;
|
|
2051
2049
|
(_a2 = this.log) == null ? void 0 : _a2.error({
|
|
2052
|
-
msg: `WebSocket error: ${ev.error}`
|
|
2050
|
+
msg: `WebSocket error: ${stringifyError(ev.error)}`
|
|
2053
2051
|
});
|
|
2054
2052
|
if (!this.#shutdown) {
|
|
2055
2053
|
if (!this.#runnerLostTimeout && this.#runnerLostThreshold && this.#runnerLostThreshold > 0) {
|
|
@@ -2074,31 +2072,27 @@ var Runner = class {
|
|
|
2074
2072
|
});
|
|
2075
2073
|
ws.addEventListener("close", async (ev) => {
|
|
2076
2074
|
var _a2, _b2, _c, _d;
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
(
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
if ((closeError == null ? void 0 : closeError.group) === "pegboard" && (closeError == null ? void 0 : closeError.error) === "runner_shutdown") {
|
|
2084
|
-
(_b2 = this.log) == null ? void 0 : _b2.info("runner shutdown");
|
|
2075
|
+
if (!this.#shutdown) {
|
|
2076
|
+
const closeError = parseWebSocketCloseReason(ev.reason);
|
|
2077
|
+
if ((closeError == null ? void 0 : closeError.group) === "ws" && (closeError == null ? void 0 : closeError.error) === "eviction") {
|
|
2078
|
+
(_a2 = this.log) == null ? void 0 : _a2.info("runner websocket evicted");
|
|
2079
|
+
this.#config.onDisconnected(ev.code, ev.reason);
|
|
2080
|
+
await this.shutdown(true);
|
|
2085
2081
|
} else {
|
|
2086
|
-
(
|
|
2082
|
+
(_b2 = this.log) == null ? void 0 : _b2.warn({
|
|
2087
2083
|
msg: "runner disconnected",
|
|
2088
2084
|
code: ev.code,
|
|
2089
2085
|
reason: ev.reason.toString(),
|
|
2090
2086
|
closeError
|
|
2091
2087
|
});
|
|
2088
|
+
this.#config.onDisconnected(ev.code, ev.reason);
|
|
2089
|
+
}
|
|
2090
|
+
if (this.#ackInterval) {
|
|
2091
|
+
clearInterval(this.#ackInterval);
|
|
2092
|
+
this.#ackInterval = void 0;
|
|
2092
2093
|
}
|
|
2093
|
-
this.#config.onDisconnected(ev.code, ev.reason);
|
|
2094
|
-
}
|
|
2095
|
-
if (this.#ackInterval) {
|
|
2096
|
-
clearInterval(this.#ackInterval);
|
|
2097
|
-
this.#ackInterval = void 0;
|
|
2098
|
-
}
|
|
2099
|
-
if (!this.#shutdown) {
|
|
2100
2094
|
if (!this.#runnerLostTimeout && this.#runnerLostThreshold && this.#runnerLostThreshold > 0) {
|
|
2101
|
-
(
|
|
2095
|
+
(_c = this.log) == null ? void 0 : _c.info({
|
|
2102
2096
|
msg: "starting runner lost timeout",
|
|
2103
2097
|
seconds: this.#runnerLostThreshold / 1e3
|
|
2104
2098
|
});
|
|
@@ -2115,6 +2109,9 @@ var Runner = class {
|
|
|
2115
2109
|
}, this.#runnerLostThreshold);
|
|
2116
2110
|
}
|
|
2117
2111
|
this.#scheduleReconnect();
|
|
2112
|
+
} else {
|
|
2113
|
+
(_d = this.log) == null ? void 0 : _d.info("websocket closed");
|
|
2114
|
+
this.#config.onDisconnected(ev.code, ev.reason);
|
|
2118
2115
|
}
|
|
2119
2116
|
});
|
|
2120
2117
|
}
|