Skip to content

Commit 9129b07

Browse files
committed
fix lint
1 parent 07450de commit 9129b07

3 files changed

Lines changed: 37 additions & 27 deletions

File tree

AGENTS.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,19 @@ npm run test:integration:orkes-v5
6161

6262
After every code change, you **must** run the following before considering the work complete:
6363

64-
1. **Unit tests** — all must pass:
64+
1. **Lint** — fix all lint errors in files you changed:
65+
```bash
66+
npm run lint # Check all files
67+
npx eslint --fix src/path/to/file.ts # Auto-fix a specific file
68+
```
69+
You must fix all lint errors in files you modified. Do not introduce new lint violations.
70+
71+
2. **Unit tests** — all must pass:
6572
```bash
6673
npm test
6774
```
6875

69-
2. **All examples** — each must complete successfully (requires a running Conductor server and `.env` credentials):
76+
3. **All examples** — each must complete successfully (requires a running Conductor server and `.env` credentials):
7077
```bash
7178
export $(cat .env | xargs)
7279
npx ts-node -P tsconfig.json --transpile-only examples/helloworld.ts

src/sdk/clients/worker/TaskRunner.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,17 @@ export class TaskRunner {
299299
*/
300300
private executeOneTask = async (task: Task): Promise<Task | undefined> => {
301301
const { workerID } = this.options;
302+
// Safe: caller (executeTask) already validated these via isValidTask()
303+
const taskId = task.taskId as string;
304+
const workflowInstanceId = task.workflowInstanceId as string;
302305
const startTime = Date.now();
303306

304307
// Publish TaskExecutionStarted event
305308
await this.eventDispatcher.publishTaskExecutionStarted({
306309
taskType: this.worker.taskDefName,
307-
taskId: task.taskId!,
310+
taskId,
308311
workerId: workerID,
309-
workflowInstanceId: task.workflowInstanceId,
312+
workflowInstanceId,
310313
timestamp: new Date(),
311314
});
312315

@@ -326,8 +329,8 @@ export class TaskRunner {
326329
if (isTaskInProgress(result)) {
327330
const contextLogs = context.getLogs();
328331
const nextTask = await this.updateTaskWithRetry(task, {
329-
workflowInstanceId: task.workflowInstanceId,
330-
taskId: task.taskId,
332+
workflowInstanceId,
333+
taskId,
331334
status: "IN_PROGRESS",
332335
callbackAfterSeconds: result.callbackAfterSeconds,
333336
outputData:
@@ -338,15 +341,15 @@ export class TaskRunner {
338341
// Publish completion event for IN_PROGRESS
339342
await this.eventDispatcher.publishTaskExecutionCompleted({
340343
taskType: this.worker.taskDefName,
341-
taskId: task.taskId!,
344+
taskId,
342345
workerId: workerID,
343-
workflowInstanceId: task.workflowInstanceId,
346+
workflowInstanceId,
344347
durationMs,
345348
timestamp: new Date(),
346349
});
347350

348351
this.logger.debug(
349-
`Task ${task.taskId} returned IN_PROGRESS, callback after ${result.callbackAfterSeconds}s`
352+
`Task ${taskId} returned IN_PROGRESS, callback after ${result.callbackAfterSeconds}s`
350353
);
351354
return nextTask;
352355
}
@@ -383,20 +386,20 @@ export class TaskRunner {
383386
// Publish TaskExecutionCompleted event
384387
await this.eventDispatcher.publishTaskExecutionCompleted({
385388
taskType: this.worker.taskDefName,
386-
taskId: task.taskId!,
389+
taskId,
387390
workerId: workerID,
388-
workflowInstanceId: task.workflowInstanceId,
391+
workflowInstanceId,
389392
durationMs,
390393
outputSizeBytes,
391394
timestamp: new Date(),
392395
});
393396

394397
const nextTask = await this.updateTaskWithRetry(task, {
395398
...merged,
396-
workflowInstanceId: task.workflowInstanceId,
397-
taskId: task.taskId,
399+
workflowInstanceId,
400+
taskId,
398401
});
399-
this.logger.debug(`Task has executed successfully ${task.taskId}`);
402+
this.logger.debug(`Task has executed successfully ${taskId}`);
400403
return nextTask;
401404
} catch (error: unknown) {
402405
const durationMs = Date.now() - startTime;
@@ -405,9 +408,9 @@ export class TaskRunner {
405408
// Publish TaskExecutionFailure event
406409
await this.eventDispatcher.publishTaskExecutionFailure({
407410
taskType: this.worker.taskDefName,
408-
taskId: task.taskId!,
411+
taskId,
409412
workerId: workerID,
410-
workflowInstanceId: task.workflowInstanceId,
413+
workflowInstanceId,
411414
cause: err,
412415
durationMs,
413416
timestamp: new Date(),
@@ -419,7 +422,7 @@ export class TaskRunner {
419422

420423
if (isNonRetryable) {
421424
this.logger.error(
422-
`Task ${task.taskId} failed with terminal error (no retry): ${err.message}`
425+
`Task ${taskId} failed with terminal error (no retry): ${err.message}`
423426
);
424427
}
425428

@@ -428,21 +431,21 @@ export class TaskRunner {
428431
{
429432
log: `${err.name}: ${err.message}${err.stack ? "\n" + err.stack : ""}`,
430433
createdTime: Date.now(),
431-
taskId: task.taskId,
434+
taskId,
432435
},
433436
];
434437

435438
const nextTask = await this.updateTaskWithRetry(task, {
436-
workflowInstanceId: task.workflowInstanceId,
437-
taskId: task.taskId,
439+
workflowInstanceId,
440+
taskId,
438441
reasonForIncompletion:
439442
(error as Record<string, string>)?.message ?? DEFAULT_ERROR_MESSAGE,
440443
status,
441444
outputData: {},
442445
logs: errorLogs,
443446
});
444447
this.errorHandler(err, task);
445-
this.logger.error(`Error executing ${task.taskId}`, error);
448+
this.logger.error(`Error executing ${taskId}`, error);
446449

447450
// Even on failure, chain to next task — the failure was for THIS task
448451
return nextTask;

src/sdk/worker/metrics/MetricsCollector.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,12 @@ export class MetricsCollector implements TaskRunnerEventsListener {
383383
const lines: string[] = [];
384384

385385
// ── Labelled counters ──
386-
const labelledCounters: Array<{
386+
const labelledCounters: {
387387
name: string;
388388
help: string;
389389
data: Map<string, number>;
390390
labelName: string;
391-
}> = [
391+
}[] = [
392392
{
393393
name: `${p}_task_poll_total`,
394394
help: "Total number of task polls",
@@ -457,11 +457,11 @@ export class MetricsCollector implements TaskRunnerEventsListener {
457457
}
458458

459459
// ── Global counters (no labels) ──
460-
const globalCounters: Array<{
460+
const globalCounters: {
461461
name: string;
462462
help: string;
463463
value: number;
464-
}> = [
464+
}[] = [
465465
{
466466
name: `${p}_thread_uncaught_exceptions_total`,
467467
help: "Total uncaught exceptions",
@@ -487,12 +487,12 @@ export class MetricsCollector implements TaskRunnerEventsListener {
487487
}
488488

489489
// ── Summaries with quantiles ──
490-
const summaries: Array<{
490+
const summaries: {
491491
name: string;
492492
help: string;
493493
data: Map<string, number[]>;
494494
labelName: string;
495-
}> = [
495+
}[] = [
496496
{
497497
name: `${p}_task_poll_time`,
498498
help: "Task poll duration in milliseconds",

0 commit comments

Comments
 (0)