Skip to content

Commit 5fa5049

Browse files
Copilotnirinchev
andauthored
fix: add null check for response.body in mongodb-downloader to fix TS2769
@types/node 22.19.x types Response.body as ReadableStream | null; the pipeline() overloads don't accept null, so add a null guard before each pipeline call so TypeScript narrows the type to ReadableStream. Agent-Logs-Url: https://github.com/mongodb-js/devtools-shared/sessions/3abd748f-532c-4c10-8829-a4eb1ed23cb2 Co-authored-by: nirinchev <2315687+nirinchev@users.noreply.github.com>
1 parent df02c6d commit 5fa5049

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/mongodb-downloader/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export class MongoDBDownloader {
142142
if (/\.tgz$|\.tar(\.[^.]+)?$/.exec(url)) {
143143
// the server's tarballs can contain hard links, which the (unmaintained?)
144144
// `download` package is unable to handle (https://github.com/kevva/decompress/issues/93)
145+
if (!response.body) throw new Error(`No response body for ${url}`);
145146
await promisify(pipeline)(
146147
response.body,
147148
tar.x({ cwd: downloadTarget, strip: isCryptLibrary ? 0 : 1 }),
@@ -151,6 +152,7 @@ export class MongoDBDownloader {
151152
downloadTarget,
152153
path.basename(new URL(url).pathname),
153154
);
155+
if (!response.body) throw new Error(`No response body for ${url}`);
154156
await promisify(pipeline)(
155157
response.body,
156158
createWriteStream(filename, { highWaterMark: MongoDBDownloader.HWM }),

0 commit comments

Comments
 (0)