From 831ec9732f94c5f696748f8c6b482740863c135a Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 31 Dec 2024 13:47:40 +0400 Subject: [PATCH] Add a small delay to allow post-build hooks to flush through 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. --- dist/main/index.js | 7 ++++++- src/main.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dist/main/index.js b/dist/main/index.js index f72a296..1b7748b 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -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, [ @@ -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; @@ -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 { diff --git a/src/main.ts b/src/main.ts index 4f40ff2..effe13c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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, [ @@ -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(); } @@ -490,6 +493,10 @@ function splitArgs(args: string): string[] { return args.split(" ").filter((arg) => arg !== ""); } +function waitFor(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + const isPost = !!core.getState("isPost"); // Main