Skip to content

Commit 3a84c8d

Browse files
authored
fix(api): update state conflict (#2800)
Signed-off-by: Ivan Dagelic <[email protected]>
1 parent e2115a0 commit 3a84c8d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/api/src/sandbox/services/sandbox.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,13 +1229,15 @@ export class SandboxService {
12291229
throw new BadRequestError('Sandbox is not in a valid state to be updated')
12301230
}
12311231

1232+
const oldState = sandbox.state
1233+
const oldDesiredState = sandbox.desiredState
12321234
sandbox.state = newState
12331235
// we need to update the desired state to match the new state
12341236
const desiredState = this.getExpectedDesiredStateForState(newState)
12351237
if (desiredState) {
12361238
sandbox.desiredState = desiredState
12371239
}
1238-
await this.sandboxRepository.saveWhere(sandbox, { pending: false, state: sandbox.state })
1240+
await this.sandboxRepository.saveWhere(sandbox, { pending: false, state: oldState, desiredState: oldDesiredState })
12391241
}
12401242

12411243
@OnEvent(WarmPoolEvents.TOPUP_REQUESTED)

0 commit comments

Comments
 (0)