Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 4dc4bbb

Browse files
committed
fix unzip stream FILE_ENDED error
1 parent 7d837fb commit 4dc4bbb

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/function/code.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ function downloadFunctionCode(options) {
3131
const zipPath = path_1.default.join(destPath, `${functionName}.zip`);
3232
const dest = fs_1.default.createWriteStream(zipPath);
3333
res.body.pipe(dest);
34-
if (!unzip) {
35-
resolve();
36-
return;
37-
}
38-
res.body.on('end', () => {
34+
dest.on('close', () => {
35+
if (!unzip) {
36+
resolve();
37+
return;
38+
}
3939
const unzipStream = unzipper_1.default.Extract({
4040
path: destPath
4141
});

src/function/code.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ export async function downloadFunctionCode(options: IFunctionCodeOptions) {
3434
const dest = fs.createWriteStream(zipPath)
3535
res.body.pipe(dest)
3636

37-
// 可选不解压 ZIP 文件
38-
if (!unzip) {
39-
resolve()
40-
return
41-
}
42-
4337
// 解压文件
44-
res.body.on('end', () => {
38+
dest.on('close', () => {
39+
// 不解压 ZIP 文件
40+
if (!unzip) {
41+
resolve()
42+
return
43+
}
44+
4545
const unzipStream = unzipper.Extract({
4646
path: destPath
4747
})

0 commit comments

Comments
 (0)