Fixing the lost of the initial state after a task recovery.

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-03-13 14:59:18 +01:00
parent 984abfa575
commit 30258837b2
2 changed files with 3 additions and 3 deletions
@@ -196,7 +196,7 @@ describe('DatabaseTaskStore', () => {
await store.claimTask();
const claimedTask = await store.getTask(taskId);
expect(claimedTask.state).toEqual({ state });
expect(claimedTask.state).toEqual({ state: state.state });
});
it('should shutdown the running task', async () => {
@@ -212,7 +212,7 @@ export class DatabaseTaskStore implements TaskStore {
try {
const spec = JSON.parse(result.spec);
const secrets = result.secrets ? JSON.parse(result.secrets) : undefined;
const state = result.state ? JSON.parse(result.state) : undefined;
const state = result.state ? JSON.parse(result.state).state : undefined;
return {
id: result.id,
spec,
@@ -272,7 +272,7 @@ export class DatabaseTaskStore implements TaskStore {
const getState = () => {
try {
return task.state ? JSON.parse(task.state) : undefined;
return task.state ? JSON.parse(task.state).state : undefined;
} catch (error) {
throw new Error(
`Failed to parse state of the task '${task.id}', ${error}`,