Skip to content

Commit

Permalink
fix: differentiated interval and initial schedule call (#5896)
Browse files Browse the repository at this point in the history
Differentiate log lines so we can see if it happens on every call, or
just on the initial call.
  • Loading branch information
Christopher Kolstad committed Jan 15, 2024
1 parent 22acadf commit 9d83929
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/lib/features/maintenance/maintenance-service.ts
Expand Up @@ -17,7 +17,7 @@ export default class MaintenanceService implements IMaintenanceStatus {

constructor(config: IUnleashConfig, settingService: SettingService) {
this.config = config;
this.logger = config.getLogger('services/pat-service.ts');
this.logger = config.getLogger('services/maintenance-service.ts');
this.settingService = settingService;
}

Expand Down
12 changes: 6 additions & 6 deletions src/lib/features/scheduler/scheduler-service.test.ts
Expand Up @@ -177,8 +177,8 @@ test('Can handle crash of a async job', async () => {

schedulerService.stop();
expect(getRecords()).toEqual([
['scheduled job failed | id: test-id-10 | async reason'],
['scheduled job failed | id: test-id-10 | async reason'],
['initial scheduled job failed | id: test-id-10 | async reason'],
['interval scheduled job failed | id: test-id-10 | async reason'],
]);
});

Expand All @@ -197,8 +197,8 @@ test('Can handle crash of a sync job', async () => {

schedulerService.stop();
expect(getRecords()).toEqual([
['scheduled job failed | id: test-id-11 | Error: sync reason'],
['scheduled job failed | id: test-id-11 | Error: sync reason'],
['initial scheduled job failed | id: test-id-11 | Error: sync reason'],
['interval scheduled job failed | id: test-id-11 | Error: sync reason'],
]);
});

Expand All @@ -217,8 +217,8 @@ test('Can handle crash of a async job', async () => {

schedulerService.stop();
expect(getRecords()).toEqual([
['scheduled job failed | id: test-id-10 | async reason'],
['scheduled job failed | id: test-id-10 | async reason'],
['initial scheduled job failed | id: test-id-10 | async reason'],
['interval scheduled job failed | id: test-id-10 | async reason'],
]);
});

Expand Down
6 changes: 4 additions & 2 deletions src/lib/features/scheduler/scheduler-service.ts
Expand Up @@ -52,7 +52,7 @@ export class SchedulerService {
}
} catch (e) {
this.logger.error(
`scheduled job failed | id: ${id} | ${e}`,
`interval scheduled job failed | id: ${id} | ${e}`,
);
}
}, timeMs).unref(),
Expand All @@ -64,7 +64,9 @@ export class SchedulerService {
await runScheduledFunctionWithEvent();
}
} catch (e) {
this.logger.error(`scheduled job failed | id: ${id} | ${e}`);
this.logger.error(
`initial scheduled job failed | id: ${id} | ${e}`,
);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/services/scheduler-service.test.ts
Expand Up @@ -101,8 +101,8 @@ test('Can handle crash of a async job', async () => {

schedulerService.stop();
expect(getRecords()).toEqual([
['scheduled job failed | id: test-id-10 | async reason'],
['scheduled job failed | id: test-id-10 | async reason'],
['initial scheduled job failed | id: test-id-10 | async reason'],
['interval scheduled job failed | id: test-id-10 | async reason'],
]);
});

Expand All @@ -116,7 +116,7 @@ test('Can handle crash of a sync job', async () => {

schedulerService.stop();
expect(getRecords()).toEqual([
['scheduled job failed | id: test-id-11 | Error: sync reason'],
['scheduled job failed | id: test-id-11 | Error: sync reason'],
['initial scheduled job failed | id: test-id-11 | Error: sync reason'],
['interval scheduled job failed | id: test-id-11 | Error: sync reason'],
]);
});

0 comments on commit 9d83929

Please sign in to comment.