Skip to content

Commit

Permalink
Add a small delay to allow post-build hooks to flush through
Browse files Browse the repository at this point in the history
It's sometimes possible for the last built store path to not get picked
up by the Cachix daemon. This delay gives the writer (Nix daemon) some
time to flush the messages through the socket before we tell our daemon
to stop listening for more paths.
  • Loading branch information
sandydoo committed Dec 31, 2024
1 parent fc82bda commit 831ec97
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 831ec97

Please sign in to comment.