Skip to content

Commit 772616c

Browse files
authored
Merge pull request #196 from cachix/fix-post-build-race
Add a small delay to allow post-build hooks to flush through
2 parents fc82bda + 831ec97 commit 772616c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

dist/main/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -28935,6 +28935,8 @@ async function upload() {
2893528935
fromBeginning: true,
2893628936
});
2893728937
daemonLog.on("line", (line) => core.info(line));
28938+
// Give the Nix daemon/socket some time to flush all the post-build hooks
28939+
await waitFor(500);
2893828940
try {
2893928941
core.debug("Waiting for Cachix daemon to exit...");
2894028942
await exec.exec(cachixBin, [
@@ -28946,7 +28948,7 @@ async function upload() {
2894628948
}
2894728949
finally {
2894828950
// Wait a bit for the logs to flush through
28949-
await new Promise((resolve) => setTimeout(resolve, 1000));
28951+
await waitFor(1000);
2895028952
daemonLog.unwatch();
2895128953
}
2895228954
break;
@@ -29119,6 +29121,9 @@ function partitionUsersAndGroups(mixedUsers) {
2911929121
function splitArgs(args) {
2912029122
return args.split(" ").filter((arg) => arg !== "");
2912129123
}
29124+
function waitFor(ms) {
29125+
return new Promise((resolve) => setTimeout(resolve, ms));
29126+
}
2912229127
const isPost = !!core.getState("isPost");
2912329128
// Main
2912429129
try {

src/main.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ async function upload() {
261261
});
262262
daemonLog.on("line", (line) => core.info(line));
263263

264+
// Give the Nix daemon/socket some time to flush all the post-build hooks
265+
await waitFor(500);
266+
264267
try {
265268
core.debug("Waiting for Cachix daemon to exit...");
266269
await exec.exec(cachixBin, [
@@ -271,7 +274,7 @@ async function upload() {
271274
]);
272275
} finally {
273276
// Wait a bit for the logs to flush through
274-
await new Promise((resolve) => setTimeout(resolve, 1000));
277+
await waitFor(1000);
275278
daemonLog.unwatch();
276279
}
277280

@@ -490,6 +493,10 @@ function splitArgs(args: string): string[] {
490493
return args.split(" ").filter((arg) => arg !== "");
491494
}
492495

496+
function waitFor(ms: number): Promise<void> {
497+
return new Promise((resolve) => setTimeout(resolve, ms));
498+
}
499+
493500
const isPost = !!core.getState("isPost");
494501

495502
// Main

0 commit comments

Comments
 (0)