Skip to content

Commit

Permalink
Merge pull request #196 from cachix/fix-post-build-race
Browse files Browse the repository at this point in the history
Add a small delay to allow post-build hooks to flush through
  • Loading branch information
sandydoo authored Jan 3, 2025
2 parents fc82bda + 831ec97 commit 772616c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28935,6 +28935,8 @@ async function upload() {
fromBeginning: true,
});
daemonLog.on("line", (line) => core.info(line));
// Give the Nix daemon/socket some time to flush all the post-build hooks
await waitFor(500);
try {
core.debug("Waiting for Cachix daemon to exit...");
await exec.exec(cachixBin, [
Expand All @@ -28946,7 +28948,7 @@ async function upload() {
}
finally {
// Wait a bit for the logs to flush through
await new Promise((resolve) => setTimeout(resolve, 1000));
await waitFor(1000);
daemonLog.unwatch();
}
break;
Expand Down Expand Up @@ -29119,6 +29121,9 @@ function partitionUsersAndGroups(mixedUsers) {
function splitArgs(args) {
return args.split(" ").filter((arg) => arg !== "");
}
function waitFor(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
const isPost = !!core.getState("isPost");
// Main
try {
Expand Down
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ async function upload() {
});
daemonLog.on("line", (line) => core.info(line));

// Give the Nix daemon/socket some time to flush all the post-build hooks
await waitFor(500);

try {
core.debug("Waiting for Cachix daemon to exit...");
await exec.exec(cachixBin, [
Expand All @@ -271,7 +274,7 @@ async function upload() {
]);
} finally {
// Wait a bit for the logs to flush through
await new Promise((resolve) => setTimeout(resolve, 1000));
await waitFor(1000);
daemonLog.unwatch();
}

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

function waitFor(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

const isPost = !!core.getState("isPost");

// Main
Expand Down

0 comments on commit 772616c

Please sign in to comment.