Merge pull request #12775 from devth/fix-missing-eventstream-end

Add missing res.end in scaffolder backend EventStream usage
This commit is contained in:
Ben Lambert
2022-07-25 22:08:23 +02:00
committed by GitHub
2 changed files with 10 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend': patch
---
Add missing `res.end()` in scaffolder backend `EventStream` usage
@@ -311,6 +311,7 @@ export async function createRouter(
logger.error(
`Received error from event stream when observing taskId '${taskId}', ${error}`,
);
res.end();
},
next: ({ events }) => {
let shouldUnsubscribe = false;
@@ -324,7 +325,10 @@ export async function createRouter(
}
// res.flush() is only available with the compression middleware
res.flush?.();
if (shouldUnsubscribe) subscription.unsubscribe();
if (shouldUnsubscribe) {
subscription.unsubscribe();
res.end();
}
},
});