From 7828186c11f36bef0a9115dd0a3c6cac94824d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 7 Mar 2025 14:12:24 +0100 Subject: [PATCH] fixup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/many-rockets-marry.md | 5 +++++ plugins/techdocs-backend/src/cache/cacheMiddleware.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/many-rockets-marry.md diff --git a/.changeset/many-rockets-marry.md b/.changeset/many-rockets-marry.md new file mode 100644 index 0000000000..896eb5ea7e --- /dev/null +++ b/.changeset/many-rockets-marry.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Minor type fix diff --git a/plugins/techdocs-backend/src/cache/cacheMiddleware.ts b/plugins/techdocs-backend/src/cache/cacheMiddleware.ts index 02b35cf7bf..78660d3c39 100644 --- a/plugins/techdocs-backend/src/cache/cacheMiddleware.ts +++ b/plugins/techdocs-backend/src/cache/cacheMiddleware.ts @@ -58,7 +58,11 @@ export const createCacheMiddleware = ({ encoding?: BufferEncoding | ErrorCallback, callback?: ErrorCallback, ) => { - chunks.push(Buffer.from(data)); + // This cast is obviously weird, but it covers a type bug in @types/node + // which does not gracefully handle union types. + chunks.push( + typeof data === 'string' ? Buffer.from(data) : Buffer.from(data), + ); if (typeof encoding === 'function') { return realWrite(data, encoding); }