Skip to content

Commit 62c0208

Browse files
committed
fix(config): await dist.zip finish so gulp task waits for write
The async `createCoreDistArchive` returned the `dest()` stream from a Promise, which async-done resolves by value rather than by re-handling the stream. That meant gulp could mark the task done before `dist.zip` finished flushing to disk, risking truncated reads from chained tasks or CI artifact uploads. Await `finish`/`end` on the write stream before resolving the task.
1 parent 181d006 commit 62c0208

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/config/gulp.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ export const createCoreDistArchive = async () => {
134134
collectFiles(src(["*.md", "license.txt"])),
135135
]);
136136

137-
return Readable.from(fileGroups.flat()).pipe(zip("dist.zip")).pipe(dest("."));
137+
// Await the destination's `finish` so gulp doesn't mark this task complete
138+
// before `dist.zip` is fully written (async-done resolves a returned Promise
139+
// by its resolved value, not by re-handling a stream the Promise resolves to).
140+
const writeStream = Readable.from(fileGroups.flat()).pipe(zip("dist.zip")).pipe(dest("."));
141+
await new Promise((resolve, reject) => {
142+
writeStream.on("finish", resolve);
143+
writeStream.on("end", resolve);
144+
writeStream.on("error", reject);
145+
});
138146
};
139147

140148
/**

0 commit comments

Comments
 (0)