Track cancelled deployments separately.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
keyhan
2026-05-18 22:15:43 +03:30
parent d5e6ab0f68
commit 68d1ccb196
10 changed files with 34 additions and 9 deletions
+3 -3
View File
@@ -32,7 +32,7 @@ interface ActiveBuildSession {
}
export interface BuildProgress {
phase: 'uploading' | 'building' | 'deploying' | 'done' | 'failed';
phase: 'uploading' | 'building' | 'deploying' | 'done' | 'failed' | 'cancelled';
percent: number;
bytesUploaded?: number;
totalBytes?: number;
@@ -98,7 +98,7 @@ export class BuildService {
async cancelBuild(deploymentId: string): Promise<void> {
const session = this.activeBuilds.get(deploymentId);
if (!session) {
this.setProgress(deploymentId, { phase: 'failed', percent: 0, message: 'Cancelled by user' });
this.setProgress(deploymentId, { phase: 'cancelled', percent: 0, message: 'Cancelled by user' });
return;
}
@@ -139,7 +139,7 @@ export class BuildService {
this.logger.log(`Cleaned up K8s build resources for deployment ${deploymentId}`);
}
this.setProgress(deploymentId, { phase: 'failed', percent: 0, message: 'Cancelled by user' });
this.setProgress(deploymentId, { phase: 'cancelled', percent: 0, message: 'Cancelled by user' });
this.activeBuilds.delete(deploymentId);
}
+1
View File
@@ -72,6 +72,7 @@ export enum DeploymentStatus {
DEPLOYING = 'deploying',
RUNNING = 'running',
FAILED = 'failed',
CANCELLED = 'cancelled',
STOPPED = 'stopped',
DELETING = 'deleting',
}
@@ -117,7 +117,7 @@ export class DeploymentsService {
if (error instanceof BuildCancelledError || error?.name === 'BuildCancelledError') {
this.logger.log(`Deployment ${deploymentId} cancelled by user`);
await this.deploymentsRepository.update(deploymentId, {
status: DeploymentStatus.FAILED,
status: DeploymentStatus.CANCELLED,
errorMessage: 'Cancelled by user',
finishedAt: new Date(),
});
@@ -209,6 +209,9 @@ export class DeploymentsService {
if (latest.status === DeploymentStatus.FAILED) {
return { phase: 'failed', percent: 0, message: latest.errorMessage || 'Deployment failed' };
}
if (latest.status === DeploymentStatus.CANCELLED) {
return { phase: 'cancelled', percent: 0, message: latest.errorMessage || 'Cancelled by user' };
}
if (latest.status === DeploymentStatus.BUILDING) {
return { phase: 'building', percent: 0, message: 'Building...' };
}
@@ -242,7 +245,7 @@ export class DeploymentsService {
await this.buildService.cancelBuild(latest.id);
await this.buildService.cleanupBuildResourcesForApp(app);
latest.status = DeploymentStatus.FAILED;
latest.status = DeploymentStatus.CANCELLED;
latest.errorMessage = 'Cancelled by user';
latest.finishedAt = new Date();
return this.deploymentsRepository.save(latest);