Skip to content

Commit

Permalink
daemon: avoid file handle GC warning
Browse files Browse the repository at this point in the history
Use openSync instread of the newer promise-based API to open the log
handle.
  • Loading branch information
sandydoo committed Jan 9, 2024
1 parent 0f0c7f6 commit 64b052b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -8130,6 +8131,14 @@ module.exports = require("node:child_process");

/***/ }),

/***/ 7561:
/***/ ((module) => {

"use strict";
module.exports = require("node:fs");

/***/ }),

/***/ 3977:
/***/ ((module) => {

Expand Down
5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -125,7 +126,7 @@ async function setup() {
name,
],
{
stdio: ['ignore', daemonLog.fd, daemonLog.fd],
stdio: ['ignore', daemonLog, daemonLog],
detached: true,
}
);
Expand Down

0 comments on commit 64b052b

Please sign in to comment.