@io-orkes/conductor-javascript 3.0.0 → 3.0.1
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/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +82 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -39160,7 +39160,7 @@ var defaultRunnerOptions = {
|
|
|
39160
39160
|
concurrency: DEFAULT_CONCURRENCY,
|
|
39161
39161
|
batchPollingTimeout: DEFAULT_BATCH_POLLING_TIMEOUT
|
|
39162
39162
|
};
|
|
39163
|
-
var TaskRunner = class {
|
|
39163
|
+
var TaskRunner = class _TaskRunner {
|
|
39164
39164
|
_client;
|
|
39165
39165
|
worker;
|
|
39166
39166
|
logger;
|
|
@@ -39285,21 +39285,94 @@ var TaskRunner = class {
|
|
|
39285
39285
|
throw error;
|
|
39286
39286
|
}
|
|
39287
39287
|
};
|
|
39288
|
+
/**
|
|
39289
|
+
* Probed once per process. null = unknown, true = v2 endpoint available,
|
|
39290
|
+
* false = legacy server (no /api/tasks/update-v2 endpoint).
|
|
39291
|
+
*/
|
|
39292
|
+
static updateV2Available = null;
|
|
39288
39293
|
updateTaskWithRetry = async (task, taskResult) => {
|
|
39289
39294
|
const { workerID } = this.options;
|
|
39290
39295
|
let retryCount = 0;
|
|
39291
39296
|
let lastError = null;
|
|
39292
39297
|
while (retryCount < this.maxRetries) {
|
|
39293
39298
|
try {
|
|
39299
|
+
if (process.env.CI) {
|
|
39300
|
+
console.log(
|
|
39301
|
+
`[TaskRunner] Submitting task result taskId=${taskResult.taskId} workflowId=${taskResult.workflowInstanceId} taskType=${this.worker.taskDefName} attempt=${retryCount + 1}/${this.maxRetries}`
|
|
39302
|
+
);
|
|
39303
|
+
}
|
|
39294
39304
|
const updateStart = Date.now();
|
|
39295
|
-
|
|
39296
|
-
|
|
39297
|
-
|
|
39298
|
-
...taskResult,
|
|
39299
|
-
|
|
39305
|
+
if (_TaskRunner.updateV2Available === false) {
|
|
39306
|
+
await TaskResource.updateTask({
|
|
39307
|
+
client: this._client,
|
|
39308
|
+
body: { ...taskResult, workerId: workerID },
|
|
39309
|
+
throwOnError: true
|
|
39310
|
+
});
|
|
39311
|
+
const updateDurationMs2 = Date.now() - updateStart;
|
|
39312
|
+
if (process.env.CI) {
|
|
39313
|
+
console.log(
|
|
39314
|
+
`[TaskRunner] Task result accepted (legacy) taskId=${taskResult.taskId} durationMs=${updateDurationMs2}`
|
|
39315
|
+
);
|
|
39300
39316
|
}
|
|
39317
|
+
await this.eventDispatcher.publishTaskUpdateCompleted({
|
|
39318
|
+
taskType: this.worker.taskDefName,
|
|
39319
|
+
taskId: taskResult.taskId ?? "",
|
|
39320
|
+
workerId: workerID,
|
|
39321
|
+
workflowInstanceId: taskResult.workflowInstanceId,
|
|
39322
|
+
durationMs: updateDurationMs2,
|
|
39323
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
39324
|
+
});
|
|
39325
|
+
return void 0;
|
|
39326
|
+
}
|
|
39327
|
+
const {
|
|
39328
|
+
data: nextTask,
|
|
39329
|
+
error,
|
|
39330
|
+
response
|
|
39331
|
+
} = await TaskResource.updateTaskV2({
|
|
39332
|
+
client: this._client,
|
|
39333
|
+
body: { ...taskResult, workerId: workerID },
|
|
39334
|
+
throwOnError: false
|
|
39301
39335
|
});
|
|
39336
|
+
if (response.status === 404 || response.status === 405) {
|
|
39337
|
+
if (_TaskRunner.updateV2Available === null) {
|
|
39338
|
+
console.log(
|
|
39339
|
+
`[TaskRunner] /api/tasks/update-v2 not available (HTTP ${response.status}), falling back to legacy /api/tasks endpoint`
|
|
39340
|
+
);
|
|
39341
|
+
_TaskRunner.updateV2Available = false;
|
|
39342
|
+
}
|
|
39343
|
+
await TaskResource.updateTask({
|
|
39344
|
+
client: this._client,
|
|
39345
|
+
body: { ...taskResult, workerId: workerID },
|
|
39346
|
+
throwOnError: true
|
|
39347
|
+
});
|
|
39348
|
+
const updateDurationMs2 = Date.now() - updateStart;
|
|
39349
|
+
if (process.env.CI) {
|
|
39350
|
+
console.log(
|
|
39351
|
+
`[TaskRunner] Task result accepted (legacy) taskId=${taskResult.taskId} durationMs=${updateDurationMs2}`
|
|
39352
|
+
);
|
|
39353
|
+
}
|
|
39354
|
+
await this.eventDispatcher.publishTaskUpdateCompleted({
|
|
39355
|
+
taskType: this.worker.taskDefName,
|
|
39356
|
+
taskId: taskResult.taskId ?? "",
|
|
39357
|
+
workerId: workerID,
|
|
39358
|
+
workflowInstanceId: taskResult.workflowInstanceId,
|
|
39359
|
+
durationMs: updateDurationMs2,
|
|
39360
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
39361
|
+
});
|
|
39362
|
+
return void 0;
|
|
39363
|
+
}
|
|
39364
|
+
if (!response.ok) {
|
|
39365
|
+
throw error ?? new Error(`Task update failed with HTTP ${response.status}`);
|
|
39366
|
+
}
|
|
39367
|
+
if (_TaskRunner.updateV2Available === null) {
|
|
39368
|
+
_TaskRunner.updateV2Available = true;
|
|
39369
|
+
}
|
|
39302
39370
|
const updateDurationMs = Date.now() - updateStart;
|
|
39371
|
+
if (process.env.CI) {
|
|
39372
|
+
console.log(
|
|
39373
|
+
`[TaskRunner] Task result accepted taskId=${taskResult.taskId} durationMs=${updateDurationMs}`
|
|
39374
|
+
);
|
|
39375
|
+
}
|
|
39303
39376
|
await this.eventDispatcher.publishTaskUpdateCompleted({
|
|
39304
39377
|
taskType: this.worker.taskDefName,
|
|
39305
39378
|
taskId: taskResult.taskId ?? "",
|
|
@@ -39316,6 +39389,9 @@ var TaskRunner = class {
|
|
|
39316
39389
|
`Error updating task ${taskResult.taskId} on retry ${retryCount + 1}/${this.maxRetries}`,
|
|
39317
39390
|
error
|
|
39318
39391
|
);
|
|
39392
|
+
console.log(
|
|
39393
|
+
`[TaskRunner] Task update failed taskId=${taskResult.taskId} attempt=${retryCount + 1}/${this.maxRetries} error=${lastError?.message ?? String(error)}`
|
|
39394
|
+
);
|
|
39319
39395
|
retryCount++;
|
|
39320
39396
|
if (retryCount < this.maxRetries) {
|
|
39321
39397
|
const delayMs = retryCount * 10 * 1e3;
|