inngest 4.2.5 → 4.3.0
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/CHANGELOG.md +18 -0
- package/api/api.cjs +1 -1
- package/api/api.js +1 -1
- package/components/Inngest.cjs +1 -1
- package/components/Inngest.d.cts +7 -1
- package/components/Inngest.d.cts.map +1 -1
- package/components/Inngest.d.ts +7 -1
- package/components/Inngest.d.ts.map +1 -1
- package/components/Inngest.js +1 -1
- package/components/InngestCommHandler.cjs +60 -28
- package/components/InngestCommHandler.cjs.map +1 -1
- package/components/InngestCommHandler.d.cts.map +1 -1
- package/components/InngestCommHandler.d.ts.map +1 -1
- package/components/InngestCommHandler.js +60 -28
- package/components/InngestCommHandler.js.map +1 -1
- package/components/InngestStepTools.cjs +3 -7
- package/components/InngestStepTools.cjs.map +1 -1
- package/components/InngestStepTools.d.cts +10 -7
- package/components/InngestStepTools.d.cts.map +1 -1
- package/components/InngestStepTools.d.ts +10 -7
- package/components/InngestStepTools.d.ts.map +1 -1
- package/components/InngestStepTools.js +3 -7
- package/components/InngestStepTools.js.map +1 -1
- package/components/connect/strategies/core/connection.cjs +91 -11
- package/components/connect/strategies/core/connection.cjs.map +1 -1
- package/components/connect/strategies/core/connection.js +91 -11
- package/components/connect/strategies/core/connection.js.map +1 -1
- package/components/connect/strategies/core/heartbeat.cjs +2 -1
- package/components/connect/strategies/core/heartbeat.cjs.map +1 -1
- package/components/connect/strategies/core/heartbeat.js +2 -1
- package/components/connect/strategies/core/heartbeat.js.map +1 -1
- package/components/connect/strategies/core/requestProcessor.cjs +27 -4
- package/components/connect/strategies/core/requestProcessor.cjs.map +1 -1
- package/components/connect/strategies/core/requestProcessor.js +27 -4
- package/components/connect/strategies/core/requestProcessor.js.map +1 -1
- package/components/connect/strategies/core/types.cjs +21 -0
- package/components/connect/strategies/core/types.cjs.map +1 -0
- package/components/connect/strategies/core/types.js +20 -0
- package/components/connect/strategies/core/types.js.map +1 -0
- package/components/connect/types.cjs.map +1 -1
- package/components/connect/types.d.cts +18 -0
- package/components/connect/types.d.cts.map +1 -1
- package/components/connect/types.d.ts +18 -0
- package/components/connect/types.d.ts.map +1 -1
- package/components/connect/types.js.map +1 -1
- package/components/execution/engine.cjs +1 -1
- package/components/execution/engine.js +1 -1
- package/components/execution/otel/middleware.d.cts +12 -6
- package/components/execution/otel/middleware.d.cts.map +1 -1
- package/components/execution/otel/middleware.d.ts +12 -6
- package/components/execution/otel/middleware.d.ts.map +1 -1
- package/components/middleware/manager.cjs +1 -1
- package/components/middleware/manager.cjs.map +1 -1
- package/components/middleware/manager.js +2 -2
- package/components/middleware/manager.js.map +1 -1
- package/components/middleware/utils.cjs +4 -3
- package/components/middleware/utils.cjs.map +1 -1
- package/components/middleware/utils.js +4 -3
- package/components/middleware/utils.js.map +1 -1
- package/components/realtime/types.d.cts +4 -4
- package/components/realtime/types.d.cts.map +1 -1
- package/components/realtime/types.d.ts +4 -4
- package/components/realtime/types.d.ts.map +1 -1
- package/helpers/consts.cjs +1 -0
- package/helpers/consts.cjs.map +1 -1
- package/helpers/consts.d.cts +1 -0
- package/helpers/consts.d.cts.map +1 -1
- package/helpers/consts.d.ts +1 -0
- package/helpers/consts.d.ts.map +1 -1
- package/helpers/consts.js +1 -0
- package/helpers/consts.js.map +1 -1
- package/helpers/env.cjs +2 -1
- package/helpers/env.cjs.map +1 -1
- package/helpers/env.js +2 -1
- package/helpers/env.js.map +1 -1
- package/helpers/net.cjs +3 -2
- package/helpers/net.cjs.map +1 -1
- package/helpers/net.js +3 -2
- package/helpers/net.js.map +1 -1
- package/helpers/strings.cjs +15 -5
- package/helpers/strings.cjs.map +1 -1
- package/helpers/strings.d.cts.map +1 -1
- package/helpers/strings.d.ts.map +1 -1
- package/helpers/strings.js +15 -6
- package/helpers/strings.js.map +1 -1
- package/helpers/temporal.cjs +2 -0
- package/helpers/temporal.d.ts +3 -0
- package/helpers/temporal.d.ts.map +1 -1
- package/helpers/temporal.js +1 -1
- package/package.json +1 -1
- package/react.d.cts.map +1 -1
- package/types.cjs.map +1 -1
- package/types.d.cts +5 -4
- package/types.d.cts.map +1 -1
- package/types.d.ts +5 -4
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/version.cjs +1 -1
- package/version.cjs.map +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
|
@@ -2,6 +2,7 @@ import { ConnectMessage, GatewayMessageType, WorkerRequestAckData, WorkerRequest
|
|
|
2
2
|
import { ensureUnsharedArrayBuffer } from "../../buffer.js";
|
|
3
3
|
import { ConnectionState } from "../../types.js";
|
|
4
4
|
import { parseGatewayExecutorRequest, parseWorkerReplyAck } from "../../messages.js";
|
|
5
|
+
import { WAKE_REASON } from "./types.js";
|
|
5
6
|
|
|
6
7
|
//#region src/components/connect/strategies/core/requestProcessor.ts
|
|
7
8
|
function toError(value) {
|
|
@@ -67,6 +68,7 @@ var RequestProcessor = class {
|
|
|
67
68
|
})).finish()));
|
|
68
69
|
this.accessor.inProgressRequests.wg.add(1);
|
|
69
70
|
this.accessor.inProgressRequests.requestLeases[gatewayExecutorRequest.requestId] = gatewayExecutorRequest.leaseId;
|
|
71
|
+
const leaseAcquiredAt = Date.now();
|
|
70
72
|
this.accessor.inProgressRequests.requestMeta[gatewayExecutorRequest.requestId] = {
|
|
71
73
|
requestId: gatewayExecutorRequest.requestId,
|
|
72
74
|
runId: gatewayExecutorRequest.runId,
|
|
@@ -74,7 +76,9 @@ var RequestProcessor = class {
|
|
|
74
76
|
appId: gatewayExecutorRequest.appId,
|
|
75
77
|
envId: gatewayExecutorRequest.envId,
|
|
76
78
|
functionSlug: gatewayExecutorRequest.functionSlug,
|
|
77
|
-
accountId: gatewayExecutorRequest.accountId
|
|
79
|
+
accountId: gatewayExecutorRequest.accountId,
|
|
80
|
+
leaseAcquiredAt,
|
|
81
|
+
leaseLastExtendedAt: leaseAcquiredAt
|
|
78
82
|
};
|
|
79
83
|
const inFlightCount = Object.keys(this.accessor.inProgressRequests.requestLeases).length;
|
|
80
84
|
this.logger.debug({
|
|
@@ -98,7 +102,11 @@ var RequestProcessor = class {
|
|
|
98
102
|
};
|
|
99
103
|
this.logger.debug({
|
|
100
104
|
connectionId: latestConn.id,
|
|
101
|
-
leaseId: currentLeaseId
|
|
105
|
+
leaseId: currentLeaseId,
|
|
106
|
+
requestId: gatewayExecutorRequest.requestId,
|
|
107
|
+
functionSlug: gatewayExecutorRequest.functionSlug,
|
|
108
|
+
runId: gatewayExecutorRequest.runId,
|
|
109
|
+
stepId: gatewayExecutorRequest.stepId
|
|
102
110
|
}, "Extending lease");
|
|
103
111
|
if (latestConn.ws.readyState !== WebSocket.OPEN) {
|
|
104
112
|
this.logger.warn({
|
|
@@ -123,6 +131,8 @@ var RequestProcessor = class {
|
|
|
123
131
|
leaseId: currentLeaseId
|
|
124
132
|
})).finish()
|
|
125
133
|
})).finish()));
|
|
134
|
+
const meta = this.accessor.inProgressRequests.requestMeta[gatewayExecutorRequest.requestId];
|
|
135
|
+
if (meta) meta.leaseLastExtendedAt = Date.now();
|
|
126
136
|
} catch (err) {
|
|
127
137
|
this.logger.warn({
|
|
128
138
|
connectionId: latestConn.id,
|
|
@@ -169,7 +179,7 @@ var RequestProcessor = class {
|
|
|
169
179
|
requestId: gatewayExecutorRequest.requestId,
|
|
170
180
|
remainingInFlight
|
|
171
181
|
}, "Request finished");
|
|
172
|
-
if (this.accessor.shutdownRequested && !this.hasInFlightRequests()) this.wakeSignal.wake();
|
|
182
|
+
if (this.accessor.shutdownRequested && !this.hasInFlightRequests()) this.wakeSignal.wake(WAKE_REASON.RequestFinishedOnShutdown);
|
|
173
183
|
}
|
|
174
184
|
}
|
|
175
185
|
/** Handle a reply ACK from the gateway. */
|
|
@@ -184,13 +194,24 @@ var RequestProcessor = class {
|
|
|
184
194
|
/** Handle a lease extension ACK from the gateway. */
|
|
185
195
|
handleExtendLeaseAck(connectMessage, connectionId) {
|
|
186
196
|
const extendLeaseAck = WorkerRequestExtendLeaseAckData.decode(connectMessage.payload);
|
|
197
|
+
const hasLease = Object.hasOwn(this.accessor.inProgressRequests.requestLeases, extendLeaseAck.requestId);
|
|
198
|
+
const meta = this.accessor.inProgressRequests.requestMeta[extendLeaseAck.requestId];
|
|
199
|
+
if (!hasLease || !meta) {
|
|
200
|
+
this.logger.debug({
|
|
201
|
+
connectionId,
|
|
202
|
+
requestId: extendLeaseAck.requestId,
|
|
203
|
+
newLeaseId: extendLeaseAck.newLeaseId,
|
|
204
|
+
hadLease: hasLease,
|
|
205
|
+
hadMeta: !!meta
|
|
206
|
+
}, "Ignoring extend lease ack for non-in-flight request");
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
187
209
|
this.logger.debug({
|
|
188
210
|
connectionId,
|
|
189
211
|
newLeaseId: extendLeaseAck.newLeaseId
|
|
190
212
|
}, "Received extend lease ack");
|
|
191
213
|
if (extendLeaseAck.newLeaseId) this.accessor.inProgressRequests.requestLeases[extendLeaseAck.requestId] = extendLeaseAck.newLeaseId;
|
|
192
214
|
else {
|
|
193
|
-
const meta = this.accessor.inProgressRequests.requestMeta[extendLeaseAck.requestId];
|
|
194
215
|
this.logger.error({
|
|
195
216
|
connectionId,
|
|
196
217
|
requestId: extendLeaseAck.requestId,
|
|
@@ -199,6 +220,8 @@ var RequestProcessor = class {
|
|
|
199
220
|
stepId: meta?.stepId
|
|
200
221
|
}, "Lease lost: the server did not renew the lease for this request. Another worker may have claimed it. The in-progress execution will continue but its result may be discarded.");
|
|
201
222
|
delete this.accessor.inProgressRequests.requestLeases[extendLeaseAck.requestId];
|
|
223
|
+
delete this.accessor.inProgressRequests.requestMeta[extendLeaseAck.requestId];
|
|
224
|
+
if (this.accessor.shutdownRequested && !this.hasInFlightRequests()) this.wakeSignal.wake(WAKE_REASON.LeaseLostOnShutdown);
|
|
202
225
|
}
|
|
203
226
|
}
|
|
204
227
|
hasInFlightRequests() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestProcessor.js","names":["accessor: ConnectionAccessor","wakeSignal: WakeSignal","callbacks: ConnectionCoreCallbacks","logger: Logger","extendLeaseInterval: ReturnType<typeof setInterval> | undefined"],"sources":["../../../../../src/components/connect/strategies/core/requestProcessor.ts"],"sourcesContent":["/**\n * Processes incoming executor requests, manages lease extensions, and handles\n * reply acknowledgements.\n *\n * Extracted from ConnectionCore so the reconcile loop orchestrator only\n * dispatches messages to this module rather than containing the full\n * execution flow inline.\n */\n\nimport type { Logger } from \"../../../../middleware/logger.ts\";\nimport {\n ConnectMessage,\n type ConnectMessage as ConnectMessageType,\n type GatewayExecutorRequestData,\n GatewayMessageType,\n WorkerRequestAckData,\n WorkerRequestExtendLeaseAckData,\n WorkerRequestExtendLeaseData,\n} from \"../../../../proto/src/components/connect/protobuf/connect.ts\";\nimport { ensureUnsharedArrayBuffer } from \"../../buffer.ts\";\nimport {\n parseGatewayExecutorRequest,\n parseWorkerReplyAck,\n} from \"../../messages.ts\";\nimport { ConnectionState } from \"../../types.ts\";\nimport type { Connection, ConnectionCoreCallbacks } from \"./connection.ts\";\nimport type { ConnectionAccessor, WakeSignal } from \"./types.ts\";\n\nfunction toError(value: unknown): Error {\n if (value instanceof Error) {\n return value;\n }\n return new Error(String(value));\n}\n\nexport class RequestProcessor {\n constructor(\n private readonly accessor: ConnectionAccessor,\n private readonly wakeSignal: WakeSignal,\n private readonly callbacks: ConnectionCoreCallbacks,\n private readonly logger: Logger,\n ) {}\n\n /** Handle an incoming executor request. */\n async handleExecutorRequest(\n connectMessage: ConnectMessageType,\n conn: Connection,\n ): Promise<void> {\n const currentState = this.callbacks.getState();\n if (currentState !== ConnectionState.ACTIVE) {\n this.logger.warn(\n { connectionId: conn.id },\n \"Received request while not active, skipping\",\n );\n return;\n }\n\n const gatewayExecutorRequest = parseGatewayExecutorRequest(\n connectMessage.payload,\n );\n\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n appId: gatewayExecutorRequest.appId,\n appName: gatewayExecutorRequest.appName,\n functionSlug: gatewayExecutorRequest.functionSlug,\n stepId: gatewayExecutorRequest.stepId,\n connectionId: conn.id,\n },\n \"Received gateway executor request\",\n );\n\n if (\n typeof gatewayExecutorRequest.appName !== \"string\" ||\n gatewayExecutorRequest.appName.length === 0\n ) {\n this.logger.warn(\n {\n requestId: gatewayExecutorRequest.requestId,\n appId: gatewayExecutorRequest.appId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n stepId: gatewayExecutorRequest.stepId,\n connectionId: conn.id,\n },\n \"No app name in request, skipping\",\n );\n return;\n }\n\n if (!this.accessor.appIds.includes(gatewayExecutorRequest.appName)) {\n this.logger.warn(\n {\n requestId: gatewayExecutorRequest.requestId,\n appId: gatewayExecutorRequest.appId,\n appName: gatewayExecutorRequest.appName,\n functionSlug: gatewayExecutorRequest.functionSlug,\n stepId: gatewayExecutorRequest.stepId,\n connectionId: conn.id,\n },\n \"No request handler found for app, skipping\",\n );\n return;\n }\n\n // Send ACK\n conn.ws.send(\n ensureUnsharedArrayBuffer(\n ConnectMessage.encode(\n ConnectMessage.create({\n kind: GatewayMessageType.WORKER_REQUEST_ACK,\n payload: WorkerRequestAckData.encode(\n WorkerRequestAckData.create({\n accountId: gatewayExecutorRequest.accountId,\n envId: gatewayExecutorRequest.envId,\n appId: gatewayExecutorRequest.appId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n requestId: gatewayExecutorRequest.requestId,\n stepId: gatewayExecutorRequest.stepId,\n userTraceCtx: gatewayExecutorRequest.userTraceCtx,\n systemTraceCtx: gatewayExecutorRequest.systemTraceCtx,\n runId: gatewayExecutorRequest.runId,\n }),\n ).finish(),\n }),\n ).finish(),\n ),\n );\n\n this.accessor.inProgressRequests.wg.add(1);\n this.accessor.inProgressRequests.requestLeases[\n gatewayExecutorRequest.requestId\n ] = gatewayExecutorRequest.leaseId;\n this.accessor.inProgressRequests.requestMeta[\n gatewayExecutorRequest.requestId\n ] = {\n requestId: gatewayExecutorRequest.requestId,\n runId: gatewayExecutorRequest.runId,\n stepId: gatewayExecutorRequest.stepId,\n appId: gatewayExecutorRequest.appId,\n envId: gatewayExecutorRequest.envId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n accountId: gatewayExecutorRequest.accountId,\n };\n\n const inFlightCount = Object.keys(\n this.accessor.inProgressRequests.requestLeases,\n ).length;\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n inFlightCount,\n },\n \"Request acknowledged\",\n );\n\n const startedAt = Date.now();\n\n // Start lease extension interval\n const originalWs = conn.ws;\n const originalConnectionId = conn.id;\n let extendLeaseInterval: ReturnType<typeof setInterval> | undefined;\n extendLeaseInterval = setInterval(() => {\n const currentLeaseId =\n this.accessor.inProgressRequests.requestLeases[\n gatewayExecutorRequest.requestId\n ];\n if (!currentLeaseId) {\n clearInterval(extendLeaseInterval);\n return;\n }\n\n // Use the current live connection's WebSocket for lease extensions.\n // During a drain, the original WebSocket may be closed by the gateway\n // while the request is still in flight.\n const latestConn = {\n ws: this.accessor.activeConnection?.ws ?? originalWs,\n id: this.accessor.activeConnection?.id ?? originalConnectionId,\n };\n\n this.logger.debug(\n { connectionId: latestConn.id, leaseId: currentLeaseId },\n \"Extending lease\",\n );\n\n if (latestConn.ws.readyState !== WebSocket.OPEN) {\n this.logger.warn(\n {\n connectionId: latestConn.id,\n requestId: gatewayExecutorRequest.requestId,\n },\n \"Cannot extend lease, no open WebSocket available\",\n );\n return;\n }\n\n try {\n latestConn.ws.send(\n ensureUnsharedArrayBuffer(\n ConnectMessage.encode(\n ConnectMessage.create({\n kind: GatewayMessageType.WORKER_REQUEST_EXTEND_LEASE,\n payload: WorkerRequestExtendLeaseData.encode(\n WorkerRequestExtendLeaseData.create({\n accountId: gatewayExecutorRequest.accountId,\n envId: gatewayExecutorRequest.envId,\n appId: gatewayExecutorRequest.appId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n requestId: gatewayExecutorRequest.requestId,\n stepId: gatewayExecutorRequest.stepId,\n runId: gatewayExecutorRequest.runId,\n userTraceCtx: gatewayExecutorRequest.userTraceCtx,\n systemTraceCtx: gatewayExecutorRequest.systemTraceCtx,\n leaseId: currentLeaseId,\n }),\n ).finish(),\n }),\n ).finish(),\n ),\n );\n } catch (err) {\n this.logger.warn(\n {\n connectionId: latestConn.id,\n requestId: gatewayExecutorRequest.requestId,\n err: toError(err),\n },\n \"Failed to send lease extension\",\n );\n }\n }, conn.extendLeaseIntervalMs);\n\n try {\n const responseBytes = await this.callbacks.handleExecutionRequest(\n gatewayExecutorRequest,\n );\n\n const durationMs = Date.now() - startedAt;\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n durationMs,\n },\n \"Request execution completed\",\n );\n\n if (!this.accessor.activeConnection) {\n this.logger.warn(\n { requestId: gatewayExecutorRequest.requestId },\n \"No current WebSocket, buffering response\",\n );\n if (this.callbacks.onBufferResponse) {\n this.callbacks.onBufferResponse(\n gatewayExecutorRequest.requestId,\n responseBytes,\n );\n }\n return;\n }\n\n this.logger.debug(\n {\n connectionId: this.accessor.activeConnection.id,\n requestId: gatewayExecutorRequest.requestId,\n },\n \"Sending worker reply\",\n );\n\n this.accessor.activeConnection.ws.send(\n ensureUnsharedArrayBuffer(\n ConnectMessage.encode(\n ConnectMessage.create({\n kind: GatewayMessageType.WORKER_REPLY,\n payload: responseBytes,\n }),\n ).finish(),\n ),\n );\n } catch (err) {\n const durationMs = Date.now() - startedAt;\n this.logger.warn(\n {\n requestId: gatewayExecutorRequest.requestId,\n durationMs,\n err: toError(err),\n },\n \"Execution error\",\n );\n } finally {\n this.accessor.inProgressRequests.wg.done();\n delete this.accessor.inProgressRequests.requestLeases[\n gatewayExecutorRequest.requestId\n ];\n delete this.accessor.inProgressRequests.requestMeta[\n gatewayExecutorRequest.requestId\n ];\n clearInterval(extendLeaseInterval);\n\n const remainingInFlight = Object.keys(\n this.accessor.inProgressRequests.requestLeases,\n ).length;\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n remainingInFlight,\n },\n \"Request finished\",\n );\n\n // Wake the loop if shutdown is pending and this was the last request\n if (this.accessor.shutdownRequested && !this.hasInFlightRequests()) {\n this.wakeSignal.wake();\n }\n }\n }\n\n /** Handle a reply ACK from the gateway. */\n handleReplyAck(\n connectMessage: ConnectMessageType,\n connectionId: string,\n ): void {\n const replyAck = parseWorkerReplyAck(connectMessage.payload);\n\n this.logger.debug(\n { connectionId, requestId: replyAck.requestId },\n \"Acknowledging reply ack\",\n );\n\n this.callbacks.onReplyAck?.(replyAck.requestId);\n }\n\n /** Handle a lease extension ACK from the gateway. */\n handleExtendLeaseAck(\n connectMessage: ConnectMessageType,\n connectionId: string,\n ): void {\n const extendLeaseAck = WorkerRequestExtendLeaseAckData.decode(\n connectMessage.payload,\n );\n\n this.logger.debug(\n { connectionId, newLeaseId: extendLeaseAck.newLeaseId },\n \"Received extend lease ack\",\n );\n\n if (extendLeaseAck.newLeaseId) {\n this.accessor.inProgressRequests.requestLeases[extendLeaseAck.requestId] =\n extendLeaseAck.newLeaseId;\n } else {\n const meta =\n this.accessor.inProgressRequests.requestMeta[extendLeaseAck.requestId];\n\n this.logger.error(\n {\n connectionId,\n requestId: extendLeaseAck.requestId,\n functionSlug: meta?.functionSlug,\n runId: meta?.runId,\n stepId: meta?.stepId,\n },\n \"Lease lost: the server did not renew the lease for this request. \" +\n \"Another worker may have claimed it. The in-progress execution \" +\n \"will continue but its result may be discarded.\",\n );\n delete this.accessor.inProgressRequests.requestLeases[\n extendLeaseAck.requestId\n ];\n }\n }\n\n private hasInFlightRequests(): boolean {\n return (\n Object.keys(this.accessor.inProgressRequests.requestLeases).length > 0\n );\n }\n}\n"],"mappings":";;;;;;AA4BA,SAAS,QAAQ,OAAuB;AACtC,KAAI,iBAAiB,MACnB,QAAO;AAET,QAAO,IAAI,MAAM,OAAO,MAAM,CAAC;;AAGjC,IAAa,mB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AAO,KAC/B,KAAK,SAAS,mBAAmB,cAClC,CAAC;AACF,QAAK,OAAO,MACV;IACE,WAAW,uBAAuB;IAClC;IACD,EACD,mBACD;AAGD,OAAI,KAAK,SAAS,qBAAqB,CAAC,KAAK,qBAAqB,CAChE,MAAK,WAAW,MAAM;;;;CAM5B,eACE,gBACA,cACM;EACN,MAAM,WAAW,oBAAoB,eAAe,QAAQ;AAE5D,OAAK,OAAO,MACV;GAAE;GAAc,WAAW,SAAS;GAAW,EAC/C,0BACD;AAED,OAAK,UAAU,aAAa,SAAS,UAAU;;;CAIjD,qBACE,gBACA,cACM;EACN,MAAM,iBAAiB,gCAAgC,OACrD,eAAe,QAChB;AAED,OAAK,OAAO,MACV;GAAE;GAAc,YAAY,eAAe;GAAY,EACvD,4BACD;AAED,MAAI,eAAe,WACjB,MAAK,SAAS,mBAAmB,cAAc,eAAe,aAC5D,eAAe;OACZ;GACL,MAAM,OACJ,KAAK,SAAS,mBAAmB,YAAY,eAAe;AAE9D,QAAK,OAAO,MACV;IACE;IACA,WAAW,eAAe;IAC1B,cAAc,MAAM;IACpB,OAAO,MAAM;IACb,QAAQ,MAAM;IACf,EACD,gLAGD;AACD,UAAO,KAAK,SAAS,mBAAmB,cACtC,eAAe;;;CAKrB,AAAQ,sBAA+B;AACrC,SACE,OAAO,KAAK,KAAK,SAAS,mBAAmB,cAAc,CAAC,SAAS"}
|
|
1
|
+
{"version":3,"file":"requestProcessor.js","names":["accessor: ConnectionAccessor","wakeSignal: WakeSignal","callbacks: ConnectionCoreCallbacks","logger: Logger","extendLeaseInterval: ReturnType<typeof setInterval> | undefined"],"sources":["../../../../../src/components/connect/strategies/core/requestProcessor.ts"],"sourcesContent":["/**\n * Processes incoming executor requests, manages lease extensions, and handles\n * reply acknowledgements.\n *\n * Extracted from ConnectionCore so the reconcile loop orchestrator only\n * dispatches messages to this module rather than containing the full\n * execution flow inline.\n */\n\nimport type { Logger } from \"../../../../middleware/logger.ts\";\nimport {\n ConnectMessage,\n type ConnectMessage as ConnectMessageType,\n GatewayMessageType,\n WorkerRequestAckData,\n WorkerRequestExtendLeaseAckData,\n WorkerRequestExtendLeaseData,\n} from \"../../../../proto/src/components/connect/protobuf/connect.ts\";\nimport { ensureUnsharedArrayBuffer } from \"../../buffer.ts\";\nimport {\n parseGatewayExecutorRequest,\n parseWorkerReplyAck,\n} from \"../../messages.ts\";\nimport { ConnectionState } from \"../../types.ts\";\nimport type { Connection, ConnectionCoreCallbacks } from \"./connection.ts\";\nimport {\n type ConnectionAccessor,\n WAKE_REASON,\n type WakeSignal,\n} from \"./types.ts\";\n\nfunction toError(value: unknown): Error {\n if (value instanceof Error) {\n return value;\n }\n return new Error(String(value));\n}\n\nexport class RequestProcessor {\n constructor(\n private readonly accessor: ConnectionAccessor,\n private readonly wakeSignal: WakeSignal,\n private readonly callbacks: ConnectionCoreCallbacks,\n private readonly logger: Logger,\n ) {}\n\n /** Handle an incoming executor request. */\n async handleExecutorRequest(\n connectMessage: ConnectMessageType,\n conn: Connection,\n ): Promise<void> {\n const currentState = this.callbacks.getState();\n if (currentState !== ConnectionState.ACTIVE) {\n this.logger.warn(\n { connectionId: conn.id },\n \"Received request while not active, skipping\",\n );\n return;\n }\n\n const gatewayExecutorRequest = parseGatewayExecutorRequest(\n connectMessage.payload,\n );\n\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n appId: gatewayExecutorRequest.appId,\n appName: gatewayExecutorRequest.appName,\n functionSlug: gatewayExecutorRequest.functionSlug,\n stepId: gatewayExecutorRequest.stepId,\n connectionId: conn.id,\n },\n \"Received gateway executor request\",\n );\n\n if (\n typeof gatewayExecutorRequest.appName !== \"string\" ||\n gatewayExecutorRequest.appName.length === 0\n ) {\n this.logger.warn(\n {\n requestId: gatewayExecutorRequest.requestId,\n appId: gatewayExecutorRequest.appId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n stepId: gatewayExecutorRequest.stepId,\n connectionId: conn.id,\n },\n \"No app name in request, skipping\",\n );\n return;\n }\n\n if (!this.accessor.appIds.includes(gatewayExecutorRequest.appName)) {\n this.logger.warn(\n {\n requestId: gatewayExecutorRequest.requestId,\n appId: gatewayExecutorRequest.appId,\n appName: gatewayExecutorRequest.appName,\n functionSlug: gatewayExecutorRequest.functionSlug,\n stepId: gatewayExecutorRequest.stepId,\n connectionId: conn.id,\n },\n \"No request handler found for app, skipping\",\n );\n return;\n }\n\n // Send ACK\n conn.ws.send(\n ensureUnsharedArrayBuffer(\n ConnectMessage.encode(\n ConnectMessage.create({\n kind: GatewayMessageType.WORKER_REQUEST_ACK,\n payload: WorkerRequestAckData.encode(\n WorkerRequestAckData.create({\n accountId: gatewayExecutorRequest.accountId,\n envId: gatewayExecutorRequest.envId,\n appId: gatewayExecutorRequest.appId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n requestId: gatewayExecutorRequest.requestId,\n stepId: gatewayExecutorRequest.stepId,\n userTraceCtx: gatewayExecutorRequest.userTraceCtx,\n systemTraceCtx: gatewayExecutorRequest.systemTraceCtx,\n runId: gatewayExecutorRequest.runId,\n }),\n ).finish(),\n }),\n ).finish(),\n ),\n );\n\n this.accessor.inProgressRequests.wg.add(1);\n this.accessor.inProgressRequests.requestLeases[\n gatewayExecutorRequest.requestId\n ] = gatewayExecutorRequest.leaseId;\n const leaseAcquiredAt = Date.now();\n this.accessor.inProgressRequests.requestMeta[\n gatewayExecutorRequest.requestId\n ] = {\n requestId: gatewayExecutorRequest.requestId,\n runId: gatewayExecutorRequest.runId,\n stepId: gatewayExecutorRequest.stepId,\n appId: gatewayExecutorRequest.appId,\n envId: gatewayExecutorRequest.envId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n accountId: gatewayExecutorRequest.accountId,\n leaseAcquiredAt,\n leaseLastExtendedAt: leaseAcquiredAt,\n };\n\n const inFlightCount = Object.keys(\n this.accessor.inProgressRequests.requestLeases,\n ).length;\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n inFlightCount,\n },\n \"Request acknowledged\",\n );\n\n const startedAt = Date.now();\n\n // Start lease extension interval\n const originalWs = conn.ws;\n const originalConnectionId = conn.id;\n let extendLeaseInterval: ReturnType<typeof setInterval> | undefined;\n extendLeaseInterval = setInterval(() => {\n const currentLeaseId =\n this.accessor.inProgressRequests.requestLeases[\n gatewayExecutorRequest.requestId\n ];\n if (!currentLeaseId) {\n clearInterval(extendLeaseInterval);\n return;\n }\n\n // Use the current live connection's WebSocket for lease extensions.\n // During a drain, the original WebSocket may be closed by the gateway\n // while the request is still in flight.\n const latestConn = {\n ws: this.accessor.activeConnection?.ws ?? originalWs,\n id: this.accessor.activeConnection?.id ?? originalConnectionId,\n };\n\n this.logger.debug(\n {\n connectionId: latestConn.id,\n leaseId: currentLeaseId,\n requestId: gatewayExecutorRequest.requestId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n runId: gatewayExecutorRequest.runId,\n stepId: gatewayExecutorRequest.stepId,\n },\n \"Extending lease\",\n );\n\n if (latestConn.ws.readyState !== WebSocket.OPEN) {\n this.logger.warn(\n {\n connectionId: latestConn.id,\n requestId: gatewayExecutorRequest.requestId,\n },\n \"Cannot extend lease, no open WebSocket available\",\n );\n return;\n }\n\n try {\n latestConn.ws.send(\n ensureUnsharedArrayBuffer(\n ConnectMessage.encode(\n ConnectMessage.create({\n kind: GatewayMessageType.WORKER_REQUEST_EXTEND_LEASE,\n payload: WorkerRequestExtendLeaseData.encode(\n WorkerRequestExtendLeaseData.create({\n accountId: gatewayExecutorRequest.accountId,\n envId: gatewayExecutorRequest.envId,\n appId: gatewayExecutorRequest.appId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n requestId: gatewayExecutorRequest.requestId,\n stepId: gatewayExecutorRequest.stepId,\n runId: gatewayExecutorRequest.runId,\n userTraceCtx: gatewayExecutorRequest.userTraceCtx,\n systemTraceCtx: gatewayExecutorRequest.systemTraceCtx,\n leaseId: currentLeaseId,\n }),\n ).finish(),\n }),\n ).finish(),\n ),\n );\n const meta =\n this.accessor.inProgressRequests.requestMeta[\n gatewayExecutorRequest.requestId\n ];\n if (meta) meta.leaseLastExtendedAt = Date.now();\n } catch (err) {\n this.logger.warn(\n {\n connectionId: latestConn.id,\n requestId: gatewayExecutorRequest.requestId,\n err: toError(err),\n },\n \"Failed to send lease extension\",\n );\n }\n }, conn.extendLeaseIntervalMs);\n\n try {\n const responseBytes = await this.callbacks.handleExecutionRequest(\n gatewayExecutorRequest,\n );\n\n const durationMs = Date.now() - startedAt;\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n functionSlug: gatewayExecutorRequest.functionSlug,\n durationMs,\n },\n \"Request execution completed\",\n );\n\n if (!this.accessor.activeConnection) {\n this.logger.warn(\n { requestId: gatewayExecutorRequest.requestId },\n \"No current WebSocket, buffering response\",\n );\n if (this.callbacks.onBufferResponse) {\n this.callbacks.onBufferResponse(\n gatewayExecutorRequest.requestId,\n responseBytes,\n );\n }\n return;\n }\n\n this.logger.debug(\n {\n connectionId: this.accessor.activeConnection.id,\n requestId: gatewayExecutorRequest.requestId,\n },\n \"Sending worker reply\",\n );\n\n this.accessor.activeConnection.ws.send(\n ensureUnsharedArrayBuffer(\n ConnectMessage.encode(\n ConnectMessage.create({\n kind: GatewayMessageType.WORKER_REPLY,\n payload: responseBytes,\n }),\n ).finish(),\n ),\n );\n } catch (err) {\n const durationMs = Date.now() - startedAt;\n this.logger.warn(\n {\n requestId: gatewayExecutorRequest.requestId,\n durationMs,\n err: toError(err),\n },\n \"Execution error\",\n );\n } finally {\n this.accessor.inProgressRequests.wg.done();\n delete this.accessor.inProgressRequests.requestLeases[\n gatewayExecutorRequest.requestId\n ];\n delete this.accessor.inProgressRequests.requestMeta[\n gatewayExecutorRequest.requestId\n ];\n clearInterval(extendLeaseInterval);\n\n const remainingInFlight = Object.keys(\n this.accessor.inProgressRequests.requestLeases,\n ).length;\n this.logger.debug(\n {\n requestId: gatewayExecutorRequest.requestId,\n remainingInFlight,\n },\n \"Request finished\",\n );\n\n // Wake the loop if shutdown is pending and this was the last request\n if (this.accessor.shutdownRequested && !this.hasInFlightRequests()) {\n this.wakeSignal.wake(WAKE_REASON.RequestFinishedOnShutdown);\n }\n }\n }\n\n /** Handle a reply ACK from the gateway. */\n handleReplyAck(\n connectMessage: ConnectMessageType,\n connectionId: string,\n ): void {\n const replyAck = parseWorkerReplyAck(connectMessage.payload);\n\n this.logger.debug(\n { connectionId, requestId: replyAck.requestId },\n \"Acknowledging reply ack\",\n );\n\n this.callbacks.onReplyAck?.(replyAck.requestId);\n }\n\n /** Handle a lease extension ACK from the gateway. */\n handleExtendLeaseAck(\n connectMessage: ConnectMessageType,\n connectionId: string,\n ): void {\n const extendLeaseAck = WorkerRequestExtendLeaseAckData.decode(\n connectMessage.payload,\n );\n\n // Late lease-extend ACKs can arrive after a request has already cleaned up\n // both maps in the completion or lease-lost path. This handler stays\n // synchronous, so once we observe the request missing from either map we\n // can safely ignore the ACK instead of recreating a stale lease entry.\n const hasLease = Object.hasOwn(\n this.accessor.inProgressRequests.requestLeases,\n extendLeaseAck.requestId,\n );\n const meta =\n this.accessor.inProgressRequests.requestMeta[extendLeaseAck.requestId];\n if (!hasLease || !meta) {\n this.logger.debug(\n {\n connectionId,\n requestId: extendLeaseAck.requestId,\n newLeaseId: extendLeaseAck.newLeaseId,\n hadLease: hasLease,\n hadMeta: !!meta,\n },\n \"Ignoring extend lease ack for non-in-flight request\",\n );\n return;\n }\n\n this.logger.debug(\n { connectionId, newLeaseId: extendLeaseAck.newLeaseId },\n \"Received extend lease ack\",\n );\n\n if (extendLeaseAck.newLeaseId) {\n this.accessor.inProgressRequests.requestLeases[extendLeaseAck.requestId] =\n extendLeaseAck.newLeaseId;\n } else {\n this.logger.error(\n {\n connectionId,\n requestId: extendLeaseAck.requestId,\n functionSlug: meta?.functionSlug,\n runId: meta?.runId,\n stepId: meta?.stepId,\n },\n \"Lease lost: the server did not renew the lease for this request. \" +\n \"Another worker may have claimed it. The in-progress execution \" +\n \"will continue but its result may be discarded.\",\n );\n delete this.accessor.inProgressRequests.requestLeases[\n extendLeaseAck.requestId\n ];\n // Also drop meta so the shutdown dump helper and debug-state snapshot\n // don't report a request we've explicitly released the lease for.\n delete this.accessor.inProgressRequests.requestMeta[\n extendLeaseAck.requestId\n ];\n\n // If this was the last in-flight request and a shutdown has been\n // requested, wake the reconcile loop so close() can observe the\n // empty lease map and exit. Without this, the loop stays parked on\n // wakeSignal.promise because the finally-block decrement in\n // handleExecutorRequest never runs (user code is still hanging).\n if (this.accessor.shutdownRequested && !this.hasInFlightRequests()) {\n this.wakeSignal.wake(WAKE_REASON.LeaseLostOnShutdown);\n }\n }\n }\n\n private hasInFlightRequests(): boolean {\n return (\n Object.keys(this.accessor.inProgressRequests.requestLeases).length > 0\n );\n }\n}\n"],"mappings":";;;;;;;AA+BA,SAAS,QAAQ,OAAuB;AACtC,KAAI,iBAAiB,MACnB,QAAO;AAET,QAAO,IAAI,MAAM,OAAO,MAAM,CAAC;;AAGjC,IAAa,mBAAb,MAA8B;CAC5B,YACE,AAAiBA,UACjB,AAAiBC,YACjB,AAAiBC,WACjB,AAAiBC,QACjB;EAJiB;EACA;EACA;EACA;;;CAInB,MAAM,sBACJ,gBACA,MACe;AAEf,MADqB,KAAK,UAAU,UAAU,KACzB,gBAAgB,QAAQ;AAC3C,QAAK,OAAO,KACV,EAAE,cAAc,KAAK,IAAI,EACzB,8CACD;AACD;;EAGF,MAAM,yBAAyB,4BAC7B,eAAe,QAChB;AAED,OAAK,OAAO,MACV;GACE,WAAW,uBAAuB;GAClC,OAAO,uBAAuB;GAC9B,SAAS,uBAAuB;GAChC,cAAc,uBAAuB;GACrC,QAAQ,uBAAuB;GAC/B,cAAc,KAAK;GACpB,EACD,oCACD;AAED,MACE,OAAO,uBAAuB,YAAY,YAC1C,uBAAuB,QAAQ,WAAW,GAC1C;AACA,QAAK,OAAO,KACV;IACE,WAAW,uBAAuB;IAClC,OAAO,uBAAuB;IAC9B,cAA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U;;;CAIjD,qBACE,gBACA,cACM;EACN,MAAM,iBAAiB,gCAAgC,OACrD,eAAe,QAChB;EAMD,MAAM,WAAW,OAAO,OACtB,KAAK,SAAS,mBAAmB,eACjC,eAAe,UAChB;EACD,MAAM,OACJ,KAAK,SAAS,mBAAmB,YAAY,eAAe;AAC9D,MAAI,CAAC,YAAY,CAAC,MAAM;AACtB,QAAK,OAAO,MACV;IACE;IACA,WAAW,eAAe;IAC1B,YAAY,eAAe;IAC3B,UAAU;IACV,SAAS,CAAC,CAAC;IACZ,EACD,sDACD;AACD;;AAGF,OAAK,OAAO,MACV;GAAE;GAAc,YAAY,eAAe;GAAY,EACvD,4BACD;AAED,MAAI,eAAe,WACjB,MAAK,SAAS,mBAAmB,cAAc,eAAe,aAC5D,eAAe;OACZ;AACL,QAAK,OAAO,MACV;IACE;IACA,WAAW,eAAe;IAC1B,cAAc,MAAM;IACpB,OAAO,MAAM;IACb,QAAQ,MAAM;IACf,EACD,gLAGD;AACD,UAAO,KAAK,SAAS,mBAAmB,cACtC,eAAe;AAIjB,UAAO,KAAK,SAAS,mBAAmB,YACtC,eAAe;AAQjB,OAAI,KAAK,SAAS,qBAAqB,CAAC,KAAK,qBAAqB,CAChE,MAAK,WAAW,KAAK,YAAY,oBAAoB;;;CAK3D,AAAQ,sBAA+B;AACrC,SACE,OAAO,KAAK,KAAK,SAAS,mBAAmB,cAAc,CAAC,SAAS"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/connect/strategies/core/types.ts
|
|
3
|
+
/**
|
|
4
|
+
* Reasons the reconcile loop may be woken. Centralised so call sites are
|
|
5
|
+
* grep-able and the "Reconcile loop woken" log carries a stable vocabulary.
|
|
6
|
+
*/
|
|
7
|
+
const WAKE_REASON = {
|
|
8
|
+
ShutdownRequested: "shutdown-requested",
|
|
9
|
+
WsError: "ws-error",
|
|
10
|
+
WsClose: "ws-close",
|
|
11
|
+
GatewayClosing: "gateway-closing",
|
|
12
|
+
HeartbeatMissed: "heartbeat-missed",
|
|
13
|
+
RequestFinishedOnShutdown: "request-finished-on-shutdown",
|
|
14
|
+
LeaseLostOnShutdown: "lease-lost-on-shutdown",
|
|
15
|
+
ShutdownStillPending: "shutdown-still-pending",
|
|
16
|
+
Unknown: "unknown"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.WAKE_REASON = WAKE_REASON;
|
|
21
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../../../../src/components/connect/strategies/core/types.ts"],"sourcesContent":["import type { WaitGroup } from \"@jpwilliams/waitgroup\";\nimport type { Mode } from \"../../../../helpers/env.ts\";\nimport type { Logger } from \"../../../../middleware/logger.ts\";\nimport type {\n GatewayExecutorRequestData,\n SDKResponse,\n} from \"../../../../proto/src/components/connect/protobuf/connect.ts\";\nimport type { Inngest } from \"../../../Inngest.ts\";\nimport type {\n ConnectDebugState,\n ConnectHandlerOptions,\n ConnectionState,\n InFlightRequest,\n} from \"../../types.ts\";\nimport type { Connection } from \"./connection.ts\";\n\n/**\n * A request handler that processes executor requests and returns SDK responses.\n */\nexport type RequestHandler = (\n msg: GatewayExecutorRequestData,\n) => Promise<SDKResponse>;\n\n/**\n * Data needed to establish a connection with the gateway.\n */\nexport interface ConnectionEstablishData {\n marshaledCapabilities: string;\n manualReadinessAck: boolean;\n apps: {\n appName: string;\n appVersion?: string;\n functions: Uint8Array;\n }[];\n}\n\n/**\n * Base configuration shared across all connection config types.\n * Contains the core fields needed for authentication and connection establishment.\n */\nexport interface BaseConnectionConfig {\n /**\n * The hashed signing key for authentication.\n */\n hashedSigningKey: string | undefined;\n\n /**\n * The hashed fallback signing key for authentication.\n */\n hashedFallbackKey: string | undefined;\n\n /**\n * The Inngest environment name.\n */\n envName: string | undefined;\n\n /**\n * Data for establishing the connection.\n */\n connectionData: ConnectionEstablishData;\n\n /**\n * The base URL for the Inngest API, as defined when constructing the Inngest\n * client (field or env var).\n */\n apiBaseUrl: string | undefined;\n\n /**\n * The mode of the Inngest client.\n */\n mode: Mode;\n}\n\n/**\n * Configuration required by connection strategies.\n * Extends BaseConnectionConfig with strategy-specific fields.\n */\nexport interface StrategyConfig extends BaseConnectionConfig {\n /**\n * The logger to use for internal logging.\n */\n internalLogger: Logger;\n\n /**\n * Request handlers mapped by app ID.\n */\n requestHandlers: Record<string, RequestHandler>;\n\n /**\n * Connection options from the user.\n */\n options: ConnectHandlerOptions;\n}\n\n/**\n * Events emitted by connection strategies.\n */\nexport interface StrategyEvents {\n /**\n * Called when the connection state changes.\n */\n onStateChange: (state: ConnectionState) => void;\n\n /**\n * Called when a connection error occurs.\n */\n onError: (error: Error) => void;\n}\n\n/**\n * Interface for connection strategies.\n *\n * A connection strategy manages the WebSocket connection to the Inngest gateway,\n * including heartbeats, lease extension, and request/response handling.\n */\nexport interface ConnectionStrategy {\n /**\n * The current state of the connection.\n */\n readonly state: ConnectionState;\n\n /**\n * The current connection ID, if connected.\n */\n readonly connectionId: string | undefined;\n\n /**\n * Establish a connection to the gateway.\n *\n * @param attempt - The current connection attempt number for exponential backoff.\n */\n connect(attempt?: number): Promise<void>;\n\n /**\n * Close the connection gracefully.\n */\n close(): Promise<void>;\n\n /**\n * A promise that resolves when the connection is fully closed.\n */\n readonly closed: Promise<void>;\n\n /**\n * Return a snapshot of debug/health information for this connection.\n */\n getDebugState(): ConnectDebugState;\n}\n\n/**\n * Narrow view of ConnectionCore state, passed to sub-modules so they can\n * read (but not mutate) the connection state they need.\n */\nexport interface ConnectionAccessor {\n readonly activeConnection: Connection | undefined;\n readonly drainingConnection: Connection | undefined;\n readonly shutdownRequested: boolean;\n readonly inProgressRequests: {\n wg: WaitGroup;\n requestLeases: Record<string, string>;\n requestMeta: Record<string, InFlightRequest>;\n };\n readonly appIds: string[];\n}\n\n/**\n * Reasons the reconcile loop may be woken. Centralised so call sites are\n * grep-able and the \"Reconcile loop woken\" log carries a stable vocabulary.\n */\nexport const WAKE_REASON = {\n ShutdownRequested: \"shutdown-requested\",\n WsError: \"ws-error\",\n WsClose: \"ws-close\",\n GatewayClosing: \"gateway-closing\",\n HeartbeatMissed: \"heartbeat-missed\",\n RequestFinishedOnShutdown: \"request-finished-on-shutdown\",\n LeaseLostOnShutdown: \"lease-lost-on-shutdown\",\n ShutdownStillPending: \"shutdown-still-pending\",\n Unknown: \"unknown\",\n} as const;\nexport type WakeReason = (typeof WAKE_REASON)[keyof typeof WAKE_REASON];\n\n/**\n * Wake signal interface for sub-modules to wake the reconcile loop.\n */\nexport interface WakeSignal {\n wake(reason?: WakeReason): void;\n}\n"],"mappings":";;;;;;AAyKA,MAAa,cAAc;CACzB,mBAAmB;CACnB,SAAS;CACT,SAAS;CACT,gBAAgB;CAChB,iBAAiB;CACjB,2BAA2B;CAC3B,qBAAqB;CACrB,sBAAsB;CACtB,SAAS;CACV"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/components/connect/strategies/core/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Reasons the reconcile loop may be woken. Centralised so call sites are
|
|
4
|
+
* grep-able and the "Reconcile loop woken" log carries a stable vocabulary.
|
|
5
|
+
*/
|
|
6
|
+
const WAKE_REASON = {
|
|
7
|
+
ShutdownRequested: "shutdown-requested",
|
|
8
|
+
WsError: "ws-error",
|
|
9
|
+
WsClose: "ws-close",
|
|
10
|
+
GatewayClosing: "gateway-closing",
|
|
11
|
+
HeartbeatMissed: "heartbeat-missed",
|
|
12
|
+
RequestFinishedOnShutdown: "request-finished-on-shutdown",
|
|
13
|
+
LeaseLostOnShutdown: "lease-lost-on-shutdown",
|
|
14
|
+
ShutdownStillPending: "shutdown-still-pending",
|
|
15
|
+
Unknown: "unknown"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { WAKE_REASON };
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/components/connect/strategies/core/types.ts"],"sourcesContent":["import type { WaitGroup } from \"@jpwilliams/waitgroup\";\nimport type { Mode } from \"../../../../helpers/env.ts\";\nimport type { Logger } from \"../../../../middleware/logger.ts\";\nimport type {\n GatewayExecutorRequestData,\n SDKResponse,\n} from \"../../../../proto/src/components/connect/protobuf/connect.ts\";\nimport type { Inngest } from \"../../../Inngest.ts\";\nimport type {\n ConnectDebugState,\n ConnectHandlerOptions,\n ConnectionState,\n InFlightRequest,\n} from \"../../types.ts\";\nimport type { Connection } from \"./connection.ts\";\n\n/**\n * A request handler that processes executor requests and returns SDK responses.\n */\nexport type RequestHandler = (\n msg: GatewayExecutorRequestData,\n) => Promise<SDKResponse>;\n\n/**\n * Data needed to establish a connection with the gateway.\n */\nexport interface ConnectionEstablishData {\n marshaledCapabilities: string;\n manualReadinessAck: boolean;\n apps: {\n appName: string;\n appVersion?: string;\n functions: Uint8Array;\n }[];\n}\n\n/**\n * Base configuration shared across all connection config types.\n * Contains the core fields needed for authentication and connection establishment.\n */\nexport interface BaseConnectionConfig {\n /**\n * The hashed signing key for authentication.\n */\n hashedSigningKey: string | undefined;\n\n /**\n * The hashed fallback signing key for authentication.\n */\n hashedFallbackKey: string | undefined;\n\n /**\n * The Inngest environment name.\n */\n envName: string | undefined;\n\n /**\n * Data for establishing the connection.\n */\n connectionData: ConnectionEstablishData;\n\n /**\n * The base URL for the Inngest API, as defined when constructing the Inngest\n * client (field or env var).\n */\n apiBaseUrl: string | undefined;\n\n /**\n * The mode of the Inngest client.\n */\n mode: Mode;\n}\n\n/**\n * Configuration required by connection strategies.\n * Extends BaseConnectionConfig with strategy-specific fields.\n */\nexport interface StrategyConfig extends BaseConnectionConfig {\n /**\n * The logger to use for internal logging.\n */\n internalLogger: Logger;\n\n /**\n * Request handlers mapped by app ID.\n */\n requestHandlers: Record<string, RequestHandler>;\n\n /**\n * Connection options from the user.\n */\n options: ConnectHandlerOptions;\n}\n\n/**\n * Events emitted by connection strategies.\n */\nexport interface StrategyEvents {\n /**\n * Called when the connection state changes.\n */\n onStateChange: (state: ConnectionState) => void;\n\n /**\n * Called when a connection error occurs.\n */\n onError: (error: Error) => void;\n}\n\n/**\n * Interface for connection strategies.\n *\n * A connection strategy manages the WebSocket connection to the Inngest gateway,\n * including heartbeats, lease extension, and request/response handling.\n */\nexport interface ConnectionStrategy {\n /**\n * The current state of the connection.\n */\n readonly state: ConnectionState;\n\n /**\n * The current connection ID, if connected.\n */\n readonly connectionId: string | undefined;\n\n /**\n * Establish a connection to the gateway.\n *\n * @param attempt - The current connection attempt number for exponential backoff.\n */\n connect(attempt?: number): Promise<void>;\n\n /**\n * Close the connection gracefully.\n */\n close(): Promise<void>;\n\n /**\n * A promise that resolves when the connection is fully closed.\n */\n readonly closed: Promise<void>;\n\n /**\n * Return a snapshot of debug/health information for this connection.\n */\n getDebugState(): ConnectDebugState;\n}\n\n/**\n * Narrow view of ConnectionCore state, passed to sub-modules so they can\n * read (but not mutate) the connection state they need.\n */\nexport interface ConnectionAccessor {\n readonly activeConnection: Connection | undefined;\n readonly drainingConnection: Connection | undefined;\n readonly shutdownRequested: boolean;\n readonly inProgressRequests: {\n wg: WaitGroup;\n requestLeases: Record<string, string>;\n requestMeta: Record<string, InFlightRequest>;\n };\n readonly appIds: string[];\n}\n\n/**\n * Reasons the reconcile loop may be woken. Centralised so call sites are\n * grep-able and the \"Reconcile loop woken\" log carries a stable vocabulary.\n */\nexport const WAKE_REASON = {\n ShutdownRequested: \"shutdown-requested\",\n WsError: \"ws-error\",\n WsClose: \"ws-close\",\n GatewayClosing: \"gateway-closing\",\n HeartbeatMissed: \"heartbeat-missed\",\n RequestFinishedOnShutdown: \"request-finished-on-shutdown\",\n LeaseLostOnShutdown: \"lease-lost-on-shutdown\",\n ShutdownStillPending: \"shutdown-still-pending\",\n Unknown: \"unknown\",\n} as const;\nexport type WakeReason = (typeof WAKE_REASON)[keyof typeof WAKE_REASON];\n\n/**\n * Wake signal interface for sub-modules to wake the reconcile loop.\n */\nexport interface WakeSignal {\n wake(reason?: WakeReason): void;\n}\n"],"mappings":";;;;;AAyKA,MAAa,cAAc;CACzB,mBAAmB;CACnB,SAAS;CACT,SAAS;CACT,gBAAgB;CAChB,iBAAiB;CACjB,2BAA2B;CAC3B,qBAAqB;CACrB,sBAAsB;CACtB,SAAS;CACV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":["import type { RegisterOptions } from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\n\nexport const DEFAULT_SHUTDOWN_SIGNALS = [\"SIGINT\", \"SIGTERM\"];\n\nexport interface ConnectApp {\n client: Inngest.Any;\n functions?: Array<InngestFunction.Like>;\n}\n\nexport interface ConnectHandlerOptions extends RegisterOptions {\n apps: ConnectApp[];\n\n /**\n * InstanceId represents a stable identifier to be used for identifying connected SDKs.\n * This can be a hostname or other identifier that remains stable across restarts.\n *\n * If nil, this defaults to the current machine's hostname.\n */\n instanceId?: string;\n\n /**\n * MaxWorkerConcurrency represents the maximum number of worker concurrency to use.\n *\n * If left undefined, there will be no limit on the number of concurrent requests on the worker.\n */\n maxWorkerConcurrency?: number;\n\n /**\n * By default, connections will be gracefully shut down when the current\n * process receives a SIGINT or SIGTERM signal. Set this to an empty array to disable this behavior.\n */\n handleShutdownSignals?: string[];\n\n /**\n * Override the gateway WebSocket endpoint. When set, this URL is used\n * instead of the endpoint returned by the Inngest API.\n *\n * Useful when there is a proxy between the worker and the gateway\n * that requires a different hostname (e.g. `ws://localhost:8100`).\n *\n * Can also be set via the `INNGEST_CONNECT_GATEWAY_URL` environment variable.\n * This option takes precedence over the env var.\n */\n gatewayUrl?: string;\n\n /**\n * Enable running the WebSocket connection, heartbeater, and lease extender\n * in a separate worker thread. This prevents thread-blocking user code from\n * interfering with connection health.\n *\n * Only works in environments that support worker_threads.\n *\n * Can also be disabled via the INNGEST_CONNECT_ISOLATE_EXECUTION=false environment variable.\n *\n * @default true\n */\n isolateExecution?: boolean;\n}\n\nexport interface WorkerConnection {\n connectionId: string;\n closed: Promise<void>;\n close: () => Promise<void>;\n state: ConnectionState;\n getDebugState: () => ConnectDebugState;\n}\n\nexport interface InFlightRequest {\n requestId: string;\n runId: string;\n stepId: string | undefined;\n appId: string;\n envId: string;\n functionSlug: string;\n accountId: string;\n}\n\nexport interface ConnectDebugState {\n /** Current connection state */\n state: ConnectionState;\n /** Active connection ID, if any */\n activeConnectionId: string | undefined;\n /** Draining connection ID (during gateway drain), if any */\n drainingConnectionId: string | undefined;\n /** Timestamp of last heartbeat we sent */\n lastHeartbeatSentAt: number | undefined;\n /** Timestamp of last heartbeat response from gateway */\n lastHeartbeatReceivedAt: number | undefined;\n /** Timestamp of last WS message received (any type) */\n lastMessageReceivedAt: number | undefined;\n /** Whether shutdown has been requested (WORKER_PAUSE sent) */\n shutdownRequested: boolean;\n /** Number of in-flight requests */\n inFlightRequestCount: number;\n /** Detailed info about in-flight requests */\n inFlightRequests: InFlightRequest[];\n}\n\nexport enum ConnectionState {\n CONNECTING = \"CONNECTING\",\n ACTIVE = \"ACTIVE\",\n PAUSED = \"PAUSED\",\n RECONNECTING = \"RECONNECTING\",\n CLOSING = \"CLOSING\",\n CLOSED = \"CLOSED\",\n}\n"],"mappings":";;AAIA,MAAa,2BAA2B,CAAC,UAAU,UAAU;
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":["import type { RegisterOptions } from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\n\nexport const DEFAULT_SHUTDOWN_SIGNALS = [\"SIGINT\", \"SIGTERM\"];\n\nexport interface ConnectApp {\n client: Inngest.Any;\n functions?: Array<InngestFunction.Like>;\n}\n\nexport interface ConnectHandlerOptions extends RegisterOptions {\n apps: ConnectApp[];\n\n /**\n * InstanceId represents a stable identifier to be used for identifying connected SDKs.\n * This can be a hostname or other identifier that remains stable across restarts.\n *\n * If nil, this defaults to the current machine's hostname.\n */\n instanceId?: string;\n\n /**\n * MaxWorkerConcurrency represents the maximum number of worker concurrency to use.\n *\n * If left undefined, there will be no limit on the number of concurrent requests on the worker.\n */\n maxWorkerConcurrency?: number;\n\n /**\n * By default, connections will be gracefully shut down when the current\n * process receives a SIGINT or SIGTERM signal. Set this to an empty array to disable this behavior.\n */\n handleShutdownSignals?: string[];\n\n /**\n * Override the gateway WebSocket endpoint. When set, this URL is used\n * instead of the endpoint returned by the Inngest API.\n *\n * Useful when there is a proxy between the worker and the gateway\n * that requires a different hostname (e.g. `ws://localhost:8100`).\n *\n * Can also be set via the `INNGEST_CONNECT_GATEWAY_URL` environment variable.\n * This option takes precedence over the env var.\n */\n gatewayUrl?: string;\n\n /**\n * Enable running the WebSocket connection, heartbeater, and lease extender\n * in a separate worker thread. This prevents thread-blocking user code from\n * interfering with connection health.\n *\n * Only works in environments that support worker_threads.\n *\n * Can also be disabled via the INNGEST_CONNECT_ISOLATE_EXECUTION=false environment variable.\n *\n * @default true\n */\n isolateExecution?: boolean;\n}\n\nexport interface WorkerConnection {\n connectionId: string;\n closed: Promise<void>;\n close: () => Promise<void>;\n state: ConnectionState;\n getDebugState: () => ConnectDebugState;\n}\n\nexport interface InFlightRequest {\n requestId: string;\n runId: string;\n stepId: string | undefined;\n appId: string;\n envId: string;\n functionSlug: string;\n accountId: string;\n /**\n * Timestamp (ms since epoch) when the worker acknowledged the request and\n * took the lease. Used to compute age for shutdown diagnostics.\n *\n * Optional so external callers constructing an `InFlightRequest` (e.g.\n * from {@link ConnectDebugState}) aren't forced to provide it.\n */\n leaseAcquiredAt?: number;\n /**\n * Timestamp (ms since epoch) of the most recent successful lease-extend send\n * for this request. Starts equal to `leaseAcquiredAt` and is updated each\n * time the worker sends a WORKER_REQUEST_EXTEND_LEASE message. Useful\n * during shutdown diagnostics to tell whether a stuck request is still\n * being actively leased or has gone silent.\n *\n * Optional for the same reason as {@link leaseAcquiredAt}.\n */\n leaseLastExtendedAt?: number;\n}\n\nexport interface ConnectDebugState {\n /** Current connection state */\n state: ConnectionState;\n /** Active connection ID, if any */\n activeConnectionId: string | undefined;\n /** Draining connection ID (during gateway drain), if any */\n drainingConnectionId: string | undefined;\n /** Timestamp of last heartbeat we sent */\n lastHeartbeatSentAt: number | undefined;\n /** Timestamp of last heartbeat response from gateway */\n lastHeartbeatReceivedAt: number | undefined;\n /** Timestamp of last WS message received (any type) */\n lastMessageReceivedAt: number | undefined;\n /** Whether shutdown has been requested (WORKER_PAUSE sent) */\n shutdownRequested: boolean;\n /** Number of in-flight requests */\n inFlightRequestCount: number;\n /** Detailed info about in-flight requests */\n inFlightRequests: InFlightRequest[];\n}\n\nexport enum ConnectionState {\n CONNECTING = \"CONNECTING\",\n ACTIVE = \"ACTIVE\",\n PAUSED = \"PAUSED\",\n RECONNECTING = \"RECONNECTING\",\n CLOSING = \"CLOSING\",\n CLOSED = \"CLOSED\",\n}\n"],"mappings":";;AAIA,MAAa,2BAA2B,CAAC,UAAU,UAAU;AAkH7D,IAAY,8DAAL;AACL;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -67,6 +67,24 @@ interface InFlightRequest {
|
|
|
67
67
|
envId: string;
|
|
68
68
|
functionSlug: string;
|
|
69
69
|
accountId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Timestamp (ms since epoch) when the worker acknowledged the request and
|
|
72
|
+
* took the lease. Used to compute age for shutdown diagnostics.
|
|
73
|
+
*
|
|
74
|
+
* Optional so external callers constructing an `InFlightRequest` (e.g.
|
|
75
|
+
* from {@link ConnectDebugState}) aren't forced to provide it.
|
|
76
|
+
*/
|
|
77
|
+
leaseAcquiredAt?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Timestamp (ms since epoch) of the most recent successful lease-extend send
|
|
80
|
+
* for this request. Starts equal to `leaseAcquiredAt` and is updated each
|
|
81
|
+
* time the worker sends a WORKER_REQUEST_EXTEND_LEASE message. Useful
|
|
82
|
+
* during shutdown diagnostics to tell whether a stuck request is still
|
|
83
|
+
* being actively leased or has gone silent.
|
|
84
|
+
*
|
|
85
|
+
* Optional for the same reason as {@link leaseAcquiredAt}.
|
|
86
|
+
*/
|
|
87
|
+
leaseLastExtendedAt?: number;
|
|
70
88
|
}
|
|
71
89
|
interface ConnectDebugState {
|
|
72
90
|
/** Current connection state */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":[],"mappings":";;;;;cAIa;UAEI,UAAA;EAFJ,MAAA,EAGH,OAAA,CAAQ,GAHL;EAEI,SAAA,CAAA,EAEH,KAFa,CAEP,eAAA,CAAgB,IAFT,CAAA;;AACjB,UAIO,qBAAA,SAA8B,eAJ7B,CAAA;MACE,EAIZ,UAJY,EAAA;;;AAGpB;;;;EAA8D,UAAA,CAAA,EAAA,MAAA;EAkD7C;;;;;sBAKM,CAAA,EAAA,MAAA;EAAiB;AAGxC;
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":[],"mappings":";;;;;cAIa;UAEI,UAAA;EAFJ,MAAA,EAGH,OAAA,CAAQ,GAHL;EAEI,SAAA,CAAA,EAEH,KAFa,CAEP,eAAA,CAAgB,IAFT,CAAA;;AACjB,UAIO,qBAAA,SAA8B,eAJ7B,CAAA;MACE,EAIZ,UAJY,EAAA;;;AAGpB;;;;EAA8D,UAAA,CAAA,EAAA,MAAA;EAkD7C;;;;;sBAKM,CAAA,EAAA,MAAA;EAAiB;AAGxC;AA4BA;;uBAES,CAAA,EAAA,MAAA,EAAA;;;AAmBT;;;;;;;;;;;;;;;;;;;;;;UAzDiB,gBAAA;;UAEP;eACK;SACN;uBACc;;UAGN,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BA,iBAAA;;SAER;;;;;;;;;;;;;;;;oBAgBW;;aAGR,eAAA"}
|
|
@@ -67,6 +67,24 @@ interface InFlightRequest {
|
|
|
67
67
|
envId: string;
|
|
68
68
|
functionSlug: string;
|
|
69
69
|
accountId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Timestamp (ms since epoch) when the worker acknowledged the request and
|
|
72
|
+
* took the lease. Used to compute age for shutdown diagnostics.
|
|
73
|
+
*
|
|
74
|
+
* Optional so external callers constructing an `InFlightRequest` (e.g.
|
|
75
|
+
* from {@link ConnectDebugState}) aren't forced to provide it.
|
|
76
|
+
*/
|
|
77
|
+
leaseAcquiredAt?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Timestamp (ms since epoch) of the most recent successful lease-extend send
|
|
80
|
+
* for this request. Starts equal to `leaseAcquiredAt` and is updated each
|
|
81
|
+
* time the worker sends a WORKER_REQUEST_EXTEND_LEASE message. Useful
|
|
82
|
+
* during shutdown diagnostics to tell whether a stuck request is still
|
|
83
|
+
* being actively leased or has gone silent.
|
|
84
|
+
*
|
|
85
|
+
* Optional for the same reason as {@link leaseAcquiredAt}.
|
|
86
|
+
*/
|
|
87
|
+
leaseLastExtendedAt?: number;
|
|
70
88
|
}
|
|
71
89
|
interface ConnectDebugState {
|
|
72
90
|
/** Current connection state */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":[],"mappings":";;;;;cAIa;UAEI,UAAA;EAFJ,MAAA,EAGH,OAAA,CAAQ,GAHL;EAEI,SAAA,CAAA,EAEH,KAFa,CAEP,eAAA,CAAgB,IAFT,CAAA;;AACjB,UAIO,qBAAA,SAA8B,eAJ7B,CAAA;MACE,EAIZ,UAJY,EAAA;;;AAGpB;;;;EAA8D,UAAA,CAAA,EAAA,MAAA;EAkD7C;;;;;sBAKM,CAAA,EAAA,MAAA;EAAiB;AAGxC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":[],"mappings":";;;;;cAIa;UAEI,UAAA;EAFJ,MAAA,EAGH,OAAA,CAAQ,GAHL;EAEI,SAAA,CAAA,EAEH,KAFa,CAEP,eAAA,CAAgB,IAFT,CAAA;;AACjB,UAIO,qBAAA,SAA8B,eAJ7B,CAAA;MACE,EAIZ,UAJY,EAAA;;;AAGpB;;;;EAA8D,UAAA,CAAA,EAAA,MAAA;EAkD7C;;;;;sBAKM,CAAA,EAAA,MAAA;EAAiB;AAGxC;AA4BA;;uBAES,CAAA,EAAA,MAAA,EAAA;;;AAmBT;;;;;;;;;;;;;;;;;;;;;;UAzDiB,gBAAA;;UAEP;eACK;SACN;uBACc;;UAGN,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;UA4BA,iBAAA;;SAER;;;;;;;;;;;;;;;;oBAgBW;;aAGR,eAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":["import type { RegisterOptions } from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\n\nexport const DEFAULT_SHUTDOWN_SIGNALS = [\"SIGINT\", \"SIGTERM\"];\n\nexport interface ConnectApp {\n client: Inngest.Any;\n functions?: Array<InngestFunction.Like>;\n}\n\nexport interface ConnectHandlerOptions extends RegisterOptions {\n apps: ConnectApp[];\n\n /**\n * InstanceId represents a stable identifier to be used for identifying connected SDKs.\n * This can be a hostname or other identifier that remains stable across restarts.\n *\n * If nil, this defaults to the current machine's hostname.\n */\n instanceId?: string;\n\n /**\n * MaxWorkerConcurrency represents the maximum number of worker concurrency to use.\n *\n * If left undefined, there will be no limit on the number of concurrent requests on the worker.\n */\n maxWorkerConcurrency?: number;\n\n /**\n * By default, connections will be gracefully shut down when the current\n * process receives a SIGINT or SIGTERM signal. Set this to an empty array to disable this behavior.\n */\n handleShutdownSignals?: string[];\n\n /**\n * Override the gateway WebSocket endpoint. When set, this URL is used\n * instead of the endpoint returned by the Inngest API.\n *\n * Useful when there is a proxy between the worker and the gateway\n * that requires a different hostname (e.g. `ws://localhost:8100`).\n *\n * Can also be set via the `INNGEST_CONNECT_GATEWAY_URL` environment variable.\n * This option takes precedence over the env var.\n */\n gatewayUrl?: string;\n\n /**\n * Enable running the WebSocket connection, heartbeater, and lease extender\n * in a separate worker thread. This prevents thread-blocking user code from\n * interfering with connection health.\n *\n * Only works in environments that support worker_threads.\n *\n * Can also be disabled via the INNGEST_CONNECT_ISOLATE_EXECUTION=false environment variable.\n *\n * @default true\n */\n isolateExecution?: boolean;\n}\n\nexport interface WorkerConnection {\n connectionId: string;\n closed: Promise<void>;\n close: () => Promise<void>;\n state: ConnectionState;\n getDebugState: () => ConnectDebugState;\n}\n\nexport interface InFlightRequest {\n requestId: string;\n runId: string;\n stepId: string | undefined;\n appId: string;\n envId: string;\n functionSlug: string;\n accountId: string;\n}\n\nexport interface ConnectDebugState {\n /** Current connection state */\n state: ConnectionState;\n /** Active connection ID, if any */\n activeConnectionId: string | undefined;\n /** Draining connection ID (during gateway drain), if any */\n drainingConnectionId: string | undefined;\n /** Timestamp of last heartbeat we sent */\n lastHeartbeatSentAt: number | undefined;\n /** Timestamp of last heartbeat response from gateway */\n lastHeartbeatReceivedAt: number | undefined;\n /** Timestamp of last WS message received (any type) */\n lastMessageReceivedAt: number | undefined;\n /** Whether shutdown has been requested (WORKER_PAUSE sent) */\n shutdownRequested: boolean;\n /** Number of in-flight requests */\n inFlightRequestCount: number;\n /** Detailed info about in-flight requests */\n inFlightRequests: InFlightRequest[];\n}\n\nexport enum ConnectionState {\n CONNECTING = \"CONNECTING\",\n ACTIVE = \"ACTIVE\",\n PAUSED = \"PAUSED\",\n RECONNECTING = \"RECONNECTING\",\n CLOSING = \"CLOSING\",\n CLOSED = \"CLOSED\",\n}\n"],"mappings":";AAIA,MAAa,2BAA2B,CAAC,UAAU,UAAU;
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/connect/types.ts"],"sourcesContent":["import type { RegisterOptions } from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\n\nexport const DEFAULT_SHUTDOWN_SIGNALS = [\"SIGINT\", \"SIGTERM\"];\n\nexport interface ConnectApp {\n client: Inngest.Any;\n functions?: Array<InngestFunction.Like>;\n}\n\nexport interface ConnectHandlerOptions extends RegisterOptions {\n apps: ConnectApp[];\n\n /**\n * InstanceId represents a stable identifier to be used for identifying connected SDKs.\n * This can be a hostname or other identifier that remains stable across restarts.\n *\n * If nil, this defaults to the current machine's hostname.\n */\n instanceId?: string;\n\n /**\n * MaxWorkerConcurrency represents the maximum number of worker concurrency to use.\n *\n * If left undefined, there will be no limit on the number of concurrent requests on the worker.\n */\n maxWorkerConcurrency?: number;\n\n /**\n * By default, connections will be gracefully shut down when the current\n * process receives a SIGINT or SIGTERM signal. Set this to an empty array to disable this behavior.\n */\n handleShutdownSignals?: string[];\n\n /**\n * Override the gateway WebSocket endpoint. When set, this URL is used\n * instead of the endpoint returned by the Inngest API.\n *\n * Useful when there is a proxy between the worker and the gateway\n * that requires a different hostname (e.g. `ws://localhost:8100`).\n *\n * Can also be set via the `INNGEST_CONNECT_GATEWAY_URL` environment variable.\n * This option takes precedence over the env var.\n */\n gatewayUrl?: string;\n\n /**\n * Enable running the WebSocket connection, heartbeater, and lease extender\n * in a separate worker thread. This prevents thread-blocking user code from\n * interfering with connection health.\n *\n * Only works in environments that support worker_threads.\n *\n * Can also be disabled via the INNGEST_CONNECT_ISOLATE_EXECUTION=false environment variable.\n *\n * @default true\n */\n isolateExecution?: boolean;\n}\n\nexport interface WorkerConnection {\n connectionId: string;\n closed: Promise<void>;\n close: () => Promise<void>;\n state: ConnectionState;\n getDebugState: () => ConnectDebugState;\n}\n\nexport interface InFlightRequest {\n requestId: string;\n runId: string;\n stepId: string | undefined;\n appId: string;\n envId: string;\n functionSlug: string;\n accountId: string;\n /**\n * Timestamp (ms since epoch) when the worker acknowledged the request and\n * took the lease. Used to compute age for shutdown diagnostics.\n *\n * Optional so external callers constructing an `InFlightRequest` (e.g.\n * from {@link ConnectDebugState}) aren't forced to provide it.\n */\n leaseAcquiredAt?: number;\n /**\n * Timestamp (ms since epoch) of the most recent successful lease-extend send\n * for this request. Starts equal to `leaseAcquiredAt` and is updated each\n * time the worker sends a WORKER_REQUEST_EXTEND_LEASE message. Useful\n * during shutdown diagnostics to tell whether a stuck request is still\n * being actively leased or has gone silent.\n *\n * Optional for the same reason as {@link leaseAcquiredAt}.\n */\n leaseLastExtendedAt?: number;\n}\n\nexport interface ConnectDebugState {\n /** Current connection state */\n state: ConnectionState;\n /** Active connection ID, if any */\n activeConnectionId: string | undefined;\n /** Draining connection ID (during gateway drain), if any */\n drainingConnectionId: string | undefined;\n /** Timestamp of last heartbeat we sent */\n lastHeartbeatSentAt: number | undefined;\n /** Timestamp of last heartbeat response from gateway */\n lastHeartbeatReceivedAt: number | undefined;\n /** Timestamp of last WS message received (any type) */\n lastMessageReceivedAt: number | undefined;\n /** Whether shutdown has been requested (WORKER_PAUSE sent) */\n shutdownRequested: boolean;\n /** Number of in-flight requests */\n inFlightRequestCount: number;\n /** Detailed info about in-flight requests */\n inFlightRequests: InFlightRequest[];\n}\n\nexport enum ConnectionState {\n CONNECTING = \"CONNECTING\",\n ACTIVE = \"ACTIVE\",\n PAUSED = \"PAUSED\",\n RECONNECTING = \"RECONNECTING\",\n CLOSING = \"CLOSING\",\n CLOSED = \"CLOSED\",\n}\n"],"mappings":";AAIA,MAAa,2BAA2B,CAAC,UAAU,UAAU;AAkH7D,IAAY,8DAAL;AACL;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -7,9 +7,9 @@ const require_types = require('../../types.cjs');
|
|
|
7
7
|
const require_InngestExecution = require('./InngestExecution.cjs');
|
|
8
8
|
const require_types$1 = require('../../helpers/types.cjs');
|
|
9
9
|
const require_functions = require('../../helpers/functions.cjs');
|
|
10
|
+
const require_temporal = require('../../helpers/temporal.cjs');
|
|
10
11
|
const require_promises = require('../../helpers/promises.cjs');
|
|
11
12
|
const require_als = require('./als.cjs');
|
|
12
|
-
const require_temporal = require('../../helpers/temporal.cjs');
|
|
13
13
|
const require_InngestStepTools = require('../InngestStepTools.cjs');
|
|
14
14
|
const require_utils = require('../middleware/utils.cjs');
|
|
15
15
|
const require_manager = require('../middleware/manager.cjs');
|
|
@@ -7,9 +7,9 @@ import { StepMode, StepOpCode, jsonErrorSchema } from "../../types.js";
|
|
|
7
7
|
import { InngestExecution } from "./InngestExecution.js";
|
|
8
8
|
import { isRecord } from "../../helpers/types.js";
|
|
9
9
|
import { undefinedToNull } from "../../helpers/functions.js";
|
|
10
|
+
import { isTemporalDuration } from "../../helpers/temporal.js";
|
|
10
11
|
import { createDeferredPromise, createDeferredPromiseWithStack, createTimeoutPromise, goIntervalTiming, resolveAfterPending, resolveNextTick, retryWithBackoff, runAsPromise } from "../../helpers/promises.js";
|
|
11
12
|
import { getAsyncCtx, getAsyncLocalStorage } from "./als.js";
|
|
12
|
-
import { isTemporalDuration } from "../../helpers/temporal.js";
|
|
13
13
|
import { STEP_INDEXING_SUFFIX, createStepTools, experimentStepRunSymbol, getStepOptions } from "../InngestStepTools.js";
|
|
14
14
|
import { UnreachableError } from "../middleware/utils.js";
|
|
15
15
|
import { MiddlewareManager } from "../middleware/manager.js";
|
|
@@ -72,11 +72,13 @@ declare const extendedTracesMiddleware: ({
|
|
|
72
72
|
ctx: {
|
|
73
73
|
tracer: _opentelemetry_api0.Tracer;
|
|
74
74
|
event: Simplify<EventPayload>;
|
|
75
|
+
events: AsTuple<Simplify<EventPayload>>;
|
|
76
|
+
runId: string;
|
|
75
77
|
step: {
|
|
76
78
|
sendEvent: (idOrOptions: StepOptionsOrId, payload: SendEventPayload) => Promise<SendEventOutput<ClientOptions>>;
|
|
77
79
|
waitForSignal: <TData>(idOrOptions: StepOptionsOrId, opts: {
|
|
78
80
|
signal: string;
|
|
79
|
-
timeout: number | string | Date;
|
|
81
|
+
timeout: number | string | Date | DurationLike | InstantLike | ZonedDateTimeLike;
|
|
80
82
|
onConflict: "replace" | "fail";
|
|
81
83
|
}) => Promise<{
|
|
82
84
|
signal: string;
|
|
@@ -91,7 +93,7 @@ declare const extendedTracesMiddleware: ({
|
|
|
91
93
|
}) => Promise<InngestApi.SendSignalResponse>;
|
|
92
94
|
waitForEvent: <TOpts extends {
|
|
93
95
|
event: string | EventType<string, any>;
|
|
94
|
-
timeout: number | string | Date;
|
|
96
|
+
timeout: number | string | Date | DurationLike | InstantLike | ZonedDateTimeLike;
|
|
95
97
|
} & ExclusiveKeys<{
|
|
96
98
|
match?: string;
|
|
97
99
|
if?: string;
|
|
@@ -149,12 +151,10 @@ declare const extendedTracesMiddleware: ({
|
|
|
149
151
|
invoke: <TFunction extends InvokeTargetFunctionDefinition>(idOrOptions: StepOptionsOrId, opts: {
|
|
150
152
|
function: TFunction;
|
|
151
153
|
} & Omit<TriggerEventFromFunction<TFunction>, "id"> & {
|
|
152
|
-
timeout?: number | string | Date;
|
|
154
|
+
timeout?: number | string | Date | DurationLike | InstantLike | ZonedDateTimeLike;
|
|
153
155
|
}) => InvocationResult<Jsonify<GetFunctionOutputRaw<TFunction>>>;
|
|
154
156
|
fetch: StepFetch;
|
|
155
157
|
};
|
|
156
|
-
events: AsTuple<Simplify<EventPayload>>;
|
|
157
|
-
runId: string;
|
|
158
158
|
group: ReturnType<typeof createGroupTools>;
|
|
159
159
|
attempt: number;
|
|
160
160
|
maxAttempts?: number | undefined;
|
|
@@ -234,7 +234,13 @@ declare const extendedTracesMiddleware: ({
|
|
|
234
234
|
};
|
|
235
235
|
readonly if?: string | undefined;
|
|
236
236
|
readonly match?: string | undefined;
|
|
237
|
-
readonly timeout?: string | number | Readonly<Date> |
|
|
237
|
+
readonly timeout?: string | number | Readonly<Date> | {
|
|
238
|
+
readonly [Symbol.toStringTag]: "Temporal.Duration";
|
|
239
|
+
} | {
|
|
240
|
+
readonly [Symbol.toStringTag]: "Temporal.Instant";
|
|
241
|
+
} | {
|
|
242
|
+
readonly [Symbol.toStringTag]: "Temporal.ZonedDateTime";
|
|
243
|
+
} | undefined;
|
|
238
244
|
}[] | undefined;
|
|
239
245
|
readonly retries?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | undefined;
|
|
240
246
|
readonly onFailure?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.cts","names":[],"sources":["../../../../src/components/execution/otel/middleware.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;UA6BiB,+BAAA;;;;;;;;;;;;;EAAA,SAAA,CAAA,EAaH,SAbG;EAA+B;;;;;AAwChD;;kBAAyC,CAAA,EAlBpB,gBAkBoB;;;;;;;UA6GO,CAAA,EAvHnC,YAuHmC;;;;;;;;;cA7GnC;;;;IAIV;;;;;;;gCAyGQ,UAAA,CAAW;;gBAA0B,mBAAA,CAAA
|
|
1
|
+
{"version":3,"file":"middleware.d.cts","names":[],"sources":["../../../../src/components/execution/otel/middleware.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;UA6BiB,+BAAA;;;;;;;;;;;;;EAAA,SAAA,CAAA,EAaH,SAbG;EAA+B;;;;;AAwChD;;kBAAyC,CAAA,EAlBpB,gBAkBoB;;;;;;;UA6GO,CAAA,EAvHnC,YAuHmC;;;;;;;;;cA7GnC;;;;IAIV;;;;;;;gCAyGQ,UAAA,CAAW;;gBAA0B,mBAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAWI,EAAA,CAAA,EAAA,MAAA;gBAAe,EAAA,CAAA,EAAA,MAAA;gBAAA,CAAA,CAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YApCb,SAAA,WAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA;cAAc,6BAAA,EAAA,mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoC3B,UAAA,CAAW,kBAAe,QAAA,UAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;KApCxB,UAAA,CAAW"}
|
|
@@ -72,11 +72,13 @@ declare const extendedTracesMiddleware: ({
|
|
|
72
72
|
ctx: {
|
|
73
73
|
tracer: _opentelemetry_api0.Tracer;
|
|
74
74
|
event: Simplify<EventPayload>;
|
|
75
|
+
events: AsTuple<Simplify<EventPayload>>;
|
|
76
|
+
runId: string;
|
|
75
77
|
step: {
|
|
76
78
|
sendEvent: (idOrOptions: StepOptionsOrId, payload: SendEventPayload) => Promise<SendEventOutput<ClientOptions>>;
|
|
77
79
|
waitForSignal: <TData>(idOrOptions: StepOptionsOrId, opts: {
|
|
78
80
|
signal: string;
|
|
79
|
-
timeout: number | string | Date;
|
|
81
|
+
timeout: number | string | Date | DurationLike | InstantLike | ZonedDateTimeLike;
|
|
80
82
|
onConflict: "replace" | "fail";
|
|
81
83
|
}) => Promise<{
|
|
82
84
|
signal: string;
|
|
@@ -91,7 +93,7 @@ declare const extendedTracesMiddleware: ({
|
|
|
91
93
|
}) => Promise<InngestApi.SendSignalResponse>;
|
|
92
94
|
waitForEvent: <TOpts extends {
|
|
93
95
|
event: string | EventType<string, any>;
|
|
94
|
-
timeout: number | string | Date;
|
|
96
|
+
timeout: number | string | Date | DurationLike | InstantLike | ZonedDateTimeLike;
|
|
95
97
|
} & ExclusiveKeys<{
|
|
96
98
|
match?: string;
|
|
97
99
|
if?: string;
|
|
@@ -149,12 +151,10 @@ declare const extendedTracesMiddleware: ({
|
|
|
149
151
|
invoke: <TFunction extends InvokeTargetFunctionDefinition>(idOrOptions: StepOptionsOrId, opts: {
|
|
150
152
|
function: TFunction;
|
|
151
153
|
} & Omit<TriggerEventFromFunction<TFunction>, "id"> & {
|
|
152
|
-
timeout?: number | string | Date;
|
|
154
|
+
timeout?: number | string | Date | DurationLike | InstantLike | ZonedDateTimeLike;
|
|
153
155
|
}) => InvocationResult<Jsonify<GetFunctionOutputRaw<TFunction>>>;
|
|
154
156
|
fetch: StepFetch;
|
|
155
157
|
};
|
|
156
|
-
events: AsTuple<Simplify<EventPayload>>;
|
|
157
|
-
runId: string;
|
|
158
158
|
group: ReturnType<typeof createGroupTools>;
|
|
159
159
|
attempt: number;
|
|
160
160
|
maxAttempts?: number | undefined;
|
|
@@ -234,7 +234,13 @@ declare const extendedTracesMiddleware: ({
|
|
|
234
234
|
};
|
|
235
235
|
readonly if?: string | undefined;
|
|
236
236
|
readonly match?: string | undefined;
|
|
237
|
-
readonly timeout?: string | number | Readonly<Date> |
|
|
237
|
+
readonly timeout?: string | number | Readonly<Date> | {
|
|
238
|
+
readonly [Symbol.toStringTag]: "Temporal.Duration";
|
|
239
|
+
} | {
|
|
240
|
+
readonly [Symbol.toStringTag]: "Temporal.Instant";
|
|
241
|
+
} | {
|
|
242
|
+
readonly [Symbol.toStringTag]: "Temporal.ZonedDateTime";
|
|
243
|
+
} | undefined;
|
|
238
244
|
}[] | undefined;
|
|
239
245
|
readonly retries?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | undefined;
|
|
240
246
|
readonly onFailure?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../../../src/components/execution/otel/middleware.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;UA6BiB,+BAAA;;;;;;;;;;;;;EAAA,SAAA,CAAA,EAaH,SAbG;EAA+B;;;;;AAwChD;;kBAAyC,CAAA,EAlBpB,gBAkBoB;;;;;;;UA6GO,CAAA,EAvHnC,YAuHmC;;;;;;;;;cA7GnC;;;;IAIV;;;;;;;gCAyGQ,UAAA,CAAW;;gBAA0B,mBAAA,CAAA
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../../../src/components/execution/otel/middleware.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;UA6BiB,+BAAA;;;;;;;;;;;;;EAAA,SAAA,CAAA,EAaH,SAbG;EAA+B;;;;;AAwChD;;kBAAyC,CAAA,EAlBpB,gBAkBoB;;;;;;;UA6GO,CAAA,EAvHnC,YAuHmC;;;;;;;;;cA7GnC;;;;IAIV;;;;;;;gCAyGQ,UAAA,CAAW;;gBAA0B,mBAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAWI,EAAA,CAAA,EAAA,MAAA;gBAAe,EAAA,CAAA,EAAA,MAAA;gBAAA,CAAA,CAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YApCb,SAAA,WAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA;cAAc,6BAAA,EAAA,mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoC3B,UAAA,CAAW,kBAAe,QAAA,UAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;KApCxB,UAAA,CAAW"}
|
|
@@ -64,7 +64,7 @@ var MiddlewareManager = class {
|
|
|
64
64
|
}
|
|
65
65
|
let opName;
|
|
66
66
|
if (stepType === "sleep" && stepInfo.input !== void 0) {
|
|
67
|
-
if (!require_utils.
|
|
67
|
+
if (!require_utils.isSleepInput(stepInfo.input[0])) throw new Error("Sleep time must be a string, number, Date, or Temporal.Duration");
|
|
68
68
|
opName = require_strings.timeStr(stepInfo.input[0]);
|
|
69
69
|
}
|
|
70
70
|
const opOpts = require_utils.optsFromStepInput(stepType, stepInfo.input);
|