Skip to content

Commit d745f7f

Browse files
jankeromnesroboquat
authored andcommitted
[ws-manager-bridge] Clean up instance tokens and track workspace stop even in irregular cases
1 parent 480e97b commit d745f7f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

components/ws-manager-bridge/src/bridge.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,18 @@ export class WorkspaceManagerBridge implements Disposable {
618618

619619
protected async markWorkspaceInstanceAsStopped(ctx: TraceContext, info: RunningWorkspaceInfo, now: Date) {
620620
const nowISO = now.toISOString();
621-
info.latestInstance.stoppingTime = nowISO;
621+
if (!info.latestInstance.stoppingTime) {
622+
info.latestInstance.stoppingTime = nowISO;
623+
}
622624
info.latestInstance.stoppedTime = nowISO;
623625
info.latestInstance.status.message = `Stopped by ws-manager-bridge. Previously in phase ${info.latestInstance.status.phase}`;
624626
info.latestInstance.status.phase = "stopped";
625627
await this.workspaceDB.trace(ctx).storeInstance(info.latestInstance);
626628

629+
// cleanup
630+
// important: call this after the DB update
631+
await this.onInstanceStopped(ctx, info.workspace.ownerId, info.latestInstance);
632+
627633
await this.messagebus.notifyOnInstanceUpdate(ctx, info.workspace.ownerId, info.latestInstance);
628634
await this.prebuildUpdater.stopPrebuildInstance(ctx, info.latestInstance);
629635
}

0 commit comments

Comments
 (0)