Skip to content

Commit

Permalink
feat(webserver, ui): avoid cancelled SSE connection from following exec
Browse files Browse the repository at this point in the history
Send a fake "start" event from the Execution following endpoint so that the UI didn't cancell it.

I'm not sure when the UI would cancel the SSE connection but it can ocurs if any of the view that opens an SSE connection are left but no event are received yet.
Sending a fake event immediatly lower the risk of occuring.
  • Loading branch information
loicmathieu committed Jan 16, 2025
1 parent b0ae3b6 commit 317cc02
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion ui/src/components/executions/ExecutionRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@
if (isEnd) {
this.closeSSE();
}
this.throttledExecutionUpdate(executionEvent);
// we are receiving a first "fake" event to force initializing the connection: ignoring it
if (executionEvent.lastEventId !== "start") {
this.throttledExecutionUpdate(executionEvent);
}
if (isEnd) {
this.throttledExecutionUpdate.flush();
}
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/executions/Topology.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@
if (isEnd) {
this.closeSubExecutionSSE(subflow);
}
this.throttledExecutionUpdate(subflow, executionEvent);
// we are receiving a first "fake" event to force initializing the connection: ignoring it
if (executionEvent.lastEventId !== "start") {
this.throttledExecutionUpdate(subflow, executionEvent);
}
if (isEnd) {
this.throttledExecutionUpdate.flush();
}
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/logs/TaskRunDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@
if (isEnd) {
this.closeExecutionSSE();
}
this.throttledExecutionUpdate(executionEvent);
// we are receiving a first "fake" event to force initializing the connection: ignoring it
if (executionEvent.lastEventId !== "start") {
this.throttledExecutionUpdate(executionEvent);
}
if (isEnd) {
this.throttledExecutionUpdate.flush();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1472,8 +1472,11 @@ public Flux<Event<Execution>> follow(

return Flux
.<Event<Execution>>create(emitter -> {
// send a first "empty" event so the SSE is correctly initialized in the frontend in case there are no logs
emitter.next(Event.of(Execution.builder().id(executionId).build()).id("start"));

// already finished execution
Execution execution = null;
Execution execution;
try {
execution = Await.until(
() -> executionRepository.findById(tenantService.resolveTenant(), executionId).orElse(null),
Expand Down

0 comments on commit 317cc02

Please sign in to comment.