Add missing res.end in scaffolder backend EventStream usage

Signed-off-by: Trevor Hartman <trevorhartman@gmail.com>
This commit is contained in:
Trevor Hartman
2022-07-21 13:42:56 -06:00
parent 7495b78b7e
commit 014b3b7776
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();
}
},
});