Skip to content

Commit abeedfd

Browse files
committed
fix(desktop): wait for Windows sidecar archive writes
1 parent f17d431 commit abeedfd

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎scripts/build-desktop-artifact.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,7 @@ export const packWindowsServerAsar = Effect.fn("packWindowsServerAsar")(function
28432843
readonly arch: typeof BuildArch.Type;
28442844
}) {
28452845
const fs = yield* FileSystem.FileSystem;
2846-
yield* Effect.tryPromise({
2846+
const archiveStream = yield* Effect.tryPromise({
28472847
try: () =>
28482848
createPackageWithOptions(input.sourceDir, input.asarPath, {
28492849
dot: true,
@@ -2852,6 +2852,21 @@ export const packWindowsServerAsar = Effect.fn("packWindowsServerAsar")(function
28522852
}),
28532853
catch: (cause) => new WindowsServerSidecarPackError({ asarPath: input.asarPath, cause }),
28542854
});
2855+
yield* Effect.tryPromise({
2856+
try: () =>
2857+
new Promise<void>((resolve, reject) => {
2858+
const stream = archiveStream as NodeJS.WritableStream & {
2859+
readonly writableFinished?: boolean;
2860+
};
2861+
if (stream.writableFinished === true) {
2862+
resolve();
2863+
return;
2864+
}
2865+
stream.once("finish", resolve);
2866+
stream.once("error", reject);
2867+
}),
2868+
catch: (cause) => new WindowsServerSidecarPackError({ asarPath: input.asarPath, cause }),
2869+
});
28552870
const unpackedDirPath = `${input.asarPath}.unpacked`;
28562871
if (!(yield* fs.exists(unpackedDirPath))) {
28572872
return yield* new WindowsServerSidecarPackError({

0 commit comments

Comments
 (0)