Skip to content

Commit 8d7ad70

Browse files
Don't leak file handles
1 parent 871bc2c commit 8d7ad70

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

dist/index.js

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,13 +1120,13 @@ class NixInstallerAction extends DetSysAction {
11201120

11211121
const logfile = this.getTemporaryName();
11221122
actionsCore.saveState(STATE_EVENT_LOG, logfile);
1123-
const output = await open(logfile, "a");
1123+
const stdout = await open(logfile, "a");
11241124
const stderr = await open(`${logfile}.stderr`, "a");
11251125

11261126
actionsCore.debug(`Event log: ${logfile}`);
11271127

11281128
const opts: SpawnOptions = {
1129-
stdio: ["ignore", output.fd, stderr.fd],
1129+
stdio: ["ignore", stdout.fd, stderr.fd],
11301130
detached: true,
11311131
};
11321132

@@ -1143,8 +1143,22 @@ class NixInstallerAction extends DetSysAction {
11431143
);
11441144

11451145
actionsCore.saveState(STATE_EVENT_PID, daemon.pid);
1146-
11471146
daemon.unref();
1147+
1148+
// Wait a tick in the event loop in order for curl to actually be running
1149+
await Promise.resolve();
1150+
1151+
try {
1152+
await stdout.close();
1153+
} catch (error) {
1154+
actionsCore.info(`Could not close curl's stdout: ${error}`);
1155+
}
1156+
1157+
try {
1158+
await stderr.close();
1159+
} catch (error) {
1160+
actionsCore.info(`Could not close curl's stderr: ${error}`);
1161+
}
11481162
}
11491163

11501164
private async slurpEventLog(): Promise<void> {

0 commit comments

Comments
 (0)