@requence/service 0.8.3-edge.1190 → 0.8.3-edge.1191
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/build/index.js
CHANGED
|
@@ -205,8 +205,9 @@ function isCallbackObject(data) {
|
|
|
205
205
|
function createCallback(callback) {
|
|
206
206
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
207
207
|
const executor = (arg) => {
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
const value = arg === undefined ? null : arg;
|
|
209
|
+
resolve2(value);
|
|
210
|
+
callback?.(value);
|
|
210
211
|
};
|
|
211
212
|
return Object.assign(executor, {
|
|
212
213
|
response() {
|
|
@@ -251,6 +252,13 @@ var durableCallbackInvocationSchema = z5.object({
|
|
|
251
252
|
arg: z5.unknown().optional(),
|
|
252
253
|
configuration: z5.unknown().optional()
|
|
253
254
|
});
|
|
255
|
+
var MAX_DURABLE_CALLBACK_ERROR_CHARS = 500;
|
|
256
|
+
var DURABLE_CALLBACK_ERROR_HEADER = "durableCallbackError";
|
|
257
|
+
var durableCallbackErrorReportSchema = z5.object({
|
|
258
|
+
nodeId: z5.string(),
|
|
259
|
+
name: z5.string(),
|
|
260
|
+
message: z5.string()
|
|
261
|
+
});
|
|
254
262
|
|
|
255
263
|
// ../helpers/src/utils/serviceRender.ts
|
|
256
264
|
import { z as z6 } from "zod/v4";
|
|
@@ -1084,7 +1092,7 @@ function createRequenceCallbackHandler() {
|
|
|
1084
1092
|
},
|
|
1085
1093
|
isReference: (value) => isCallbackObject(value),
|
|
1086
1094
|
deserialize(ref, ctx) {
|
|
1087
|
-
return (arg) => {
|
|
1095
|
+
return (arg = null) => {
|
|
1088
1096
|
ctx.onCallbackInvoke?.({ ...ref, arg });
|
|
1089
1097
|
};
|
|
1090
1098
|
}
|
|
@@ -2000,7 +2008,7 @@ function createConnection({
|
|
|
2000
2008
|
clientProperties: {
|
|
2001
2009
|
...connectionOptions?.clientProperties,
|
|
2002
2010
|
...buildServiceClientProperties({
|
|
2003
|
-
libVersion: "javascript@0.8.3-edge.
|
|
2011
|
+
libVersion: "javascript@0.8.3-edge.1191",
|
|
2004
2012
|
serviceVersion: version,
|
|
2005
2013
|
connectionId,
|
|
2006
2014
|
prefetch,
|
|
@@ -2142,6 +2150,28 @@ function createConnection({
|
|
|
2142
2150
|
simple_default.error(`Requence: could not report a failed surface interaction on |${params.surface}|:`, error instanceof Error ? error.message : error);
|
|
2143
2151
|
});
|
|
2144
2152
|
};
|
|
2153
|
+
const reportCallbackFailure = (payload, error) => {
|
|
2154
|
+
const parsed = durableCallbackInvocationSchema.safeParse(payload);
|
|
2155
|
+
if (!parsed.success) {
|
|
2156
|
+
simple_default.error("Requence: cannot report a failed durable callback — the invocation names no task and node");
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
const { taskId, nodeId, name: name2 } = parsed.data;
|
|
2160
|
+
channelWrapper.publish(exchange, "", Buffer.from(JSON.stringify({
|
|
2161
|
+
nodeId,
|
|
2162
|
+
name: name2,
|
|
2163
|
+
message: (error instanceof Error ? error.message : String(error)).slice(0, MAX_DURABLE_CALLBACK_ERROR_CHARS)
|
|
2164
|
+
})), {
|
|
2165
|
+
contentType: "application/json",
|
|
2166
|
+
persistent: true,
|
|
2167
|
+
headers: {
|
|
2168
|
+
taskId,
|
|
2169
|
+
[DURABLE_CALLBACK_ERROR_HEADER]: true
|
|
2170
|
+
}
|
|
2171
|
+
}).catch((publishError) => {
|
|
2172
|
+
simple_default.error(`Requence: could not report the failed durable callback |${name2}| of task |${taskId}|:`, publishError instanceof Error ? publishError.message : publishError);
|
|
2173
|
+
});
|
|
2174
|
+
};
|
|
2145
2175
|
const announceResume = (params) => {
|
|
2146
2176
|
channelWrapper.publish(exchange, "", Buffer.from(JSON.stringify({ messageId: params.messageId })), {
|
|
2147
2177
|
correlationId: params.messageId,
|
|
@@ -2252,10 +2282,13 @@ function createConnection({
|
|
|
2252
2282
|
if (!message) {
|
|
2253
2283
|
return;
|
|
2254
2284
|
}
|
|
2285
|
+
let payload;
|
|
2255
2286
|
try {
|
|
2256
|
-
|
|
2287
|
+
payload = JSON.parse(message.content.toString());
|
|
2288
|
+
await runDurableCallbackInvocation(payload);
|
|
2257
2289
|
} catch (error) {
|
|
2258
2290
|
simple_default.error("Requence: durable callback threw:", error instanceof Error ? error.stack ?? error.message : error);
|
|
2291
|
+
reportCallbackFailure(payload, error);
|
|
2259
2292
|
}
|
|
2260
2293
|
safeAck(channel, message);
|
|
2261
2294
|
});
|
|
@@ -2536,7 +2569,7 @@ function createConnection({
|
|
|
2536
2569
|
begin: true,
|
|
2537
2570
|
epoch,
|
|
2538
2571
|
...buildServiceIdentityHeaders({
|
|
2539
|
-
libVersion: "javascript@0.8.3-edge.
|
|
2572
|
+
libVersion: "javascript@0.8.3-edge.1191",
|
|
2540
2573
|
name,
|
|
2541
2574
|
holdsSlot: !(isGeneratorHandler && mode === "CONTINUOUS")
|
|
2542
2575
|
})
|
|
@@ -3107,5 +3140,5 @@ export {
|
|
|
3107
3140
|
PayloadTooLargeError
|
|
3108
3141
|
};
|
|
3109
3142
|
|
|
3110
|
-
//# debugId=
|
|
3143
|
+
//# debugId=8CEE2F38CC05117264756E2164756E21
|
|
3111
3144
|
//# sourceMappingURL=index.js.map
|