From 64b052b234bb16af1d1e3951c65532cba80a3f05 Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 9 Jan 2024 22:40:55 +0000 Subject: [PATCH] daemon: avoid file handle GC warning Use openSync instread of the newer promise-based API to open the log handle. --- dist/main/index.js | 13 +++++++++++-- src/main.ts | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dist/main/index.js b/dist/main/index.js index 0be6b544..924900af 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -7729,6 +7729,7 @@ const core = __importStar(__nccwpck_require__(2186)); const exec = __importStar(__nccwpck_require__(1514)); const node_child_process_1 = __nccwpck_require__(7718); const fs = __importStar(__nccwpck_require__(3977)); +const node_fs_1 = __nccwpck_require__(7561); const os = __importStar(__nccwpck_require__(612)); const path = __importStar(__nccwpck_require__(9411)); const tail_1 = __nccwpck_require__(5824); @@ -7827,13 +7828,13 @@ async function setup() { if (useDaemon && supportsDaemon) { const tmpdir = process.env['RUNNER_TEMP'] ?? os.tmpdir(); const daemonDir = await fs.mkdtemp(path.join(tmpdir, 'cachix-daemon-')); - const daemonLog = await fs.open(`${daemonDir}/daemon.log`, 'a'); + const daemonLog = (0, node_fs_1.openSync)(`${daemonDir}/daemon.log`, 'a'); const daemon = (0, node_child_process_1.spawn)(cachixBin, [ 'daemon', 'run', '--socket', `${daemonDir}/daemon.sock`, name, ], { - stdio: ['ignore', daemonLog.fd, daemonLog.fd], + stdio: ['ignore', daemonLog, daemonLog], detached: true, }); daemon.on('error', (err) => { @@ -8130,6 +8131,14 @@ module.exports = require("node:child_process"); /***/ }), +/***/ 7561: +/***/ ((module) => { + +"use strict"; +module.exports = require("node:fs"); + +/***/ }), + /***/ 3977: /***/ ((module) => { diff --git a/src/main.ts b/src/main.ts index 1088e120..752be59d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,6 +2,7 @@ import * as core from '@actions/core'; import * as exec from '@actions/exec'; import { spawn } from 'node:child_process'; import * as fs from 'node:fs/promises'; +import { openSync } from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { Tail } from 'tail'; @@ -115,7 +116,7 @@ async function setup() { if (useDaemon && supportsDaemon) { const tmpdir = process.env['RUNNER_TEMP'] ?? os.tmpdir(); const daemonDir = await fs.mkdtemp(path.join(tmpdir, 'cachix-daemon-')); - const daemonLog = await fs.open(`${daemonDir}/daemon.log`, 'a'); + const daemonLog = openSync(`${daemonDir}/daemon.log`, 'a'); const daemon = spawn( cachixBin, @@ -125,7 +126,7 @@ async function setup() { name, ], { - stdio: ['ignore', daemonLog.fd, daemonLog.fd], + stdio: ['ignore', daemonLog, daemonLog], detached: true, } );