Skip to content

Commit

Permalink
fix(cloud): send "sessionFailed" event if result has errors
Browse files Browse the repository at this point in the history
Previously we'd send a "sessionCompleted" event which caused Cloud to
display the wrong command status.
  • Loading branch information
eysi09 committed Jul 10, 2023
1 parent 5d9fb08 commit e4c5c93
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/src/cloud/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export type ApiFetchResponse<T> = T & {

// TODO: Read this from the `api-types` package once the session registration logic has been released in Cloud.
export interface CloudSessionResponse {
environmentId: number
namespaceId: number
environmentId: string
namespaceId: string
shortId: string
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/cloud/buffered-event-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ interface ApiBatchBase {

export interface ApiEventBatch extends ApiBatchBase {
events: StreamEvent[]
environmentId?: number
namespaceId?: number
environmentId?: string
namespaceId?: string
// TODO: Remove the `environment` and `namespace` params once we no longer need to support Cloud/Enterprise
// versions that expect them.
environment: string
Expand Down
6 changes: 5 additions & 1 deletion core/src/commands/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,11 @@ export abstract class Command<A extends Parameters = {}, O extends Parameters =
parentSessionId || undefined
)

cloudEventStream.emit("sessionCompleted", {})
if (allErrors.length > 0) {
cloudEventStream.emit("sessionFailed", {})
} else {
cloudEventStream.emit("sessionCompleted", {})
}
} catch (err) {
analytics?.trackCommandResult(
this.getFullName(),
Expand Down
4 changes: 2 additions & 2 deletions core/src/events/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ export type GraphResultEventPayload = Omit<GraphResult, "result" | "task" | "dep
export interface CommandInfoPayload extends CommandInfo {
// Contains additional context for the command info available during init
environmentName: string
environmentId: number | undefined
environmentId?: string
projectName: string
projectId: string
namespaceName: string
namespaceId: number | undefined
namespaceId?: string
coreVersion: string
vcsBranch: string
vcsCommitHash: string
Expand Down

0 comments on commit e4c5c93

Please sign in to comment.