Skip to content
This repository was archived by the owner on Apr 24, 2026. It is now read-only.

Commit ac45586

Browse files
lanmowerclaude
andcommitted
fix: Windows binary extension and premature tempdir cleanup for rust/c/cpp
- Add .exe extension to compiled binary output on Windows - Remove premature cleanup() call before running compiled binary (was deleting the exe before spawn) - Add cleanup() to go/compile-failure branch that was missing it Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8437471 commit ac45586

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/workers/isolation-worker.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,14 @@ async function executeInProcess(code, runtime, workingDirectory, processTimeout)
145145
let execStdout = '';
146146
let execKilled = false;
147147

148+
const binExt = IS_WIN ? '.exe' : '';
149+
const binName = `code${binExt}`;
148150
const args = runtime === 'go'
149151
? ['run', filePath]
150152
: runtime === 'rust'
151-
? [filePath, '-o', path.join(tempDir, 'code')]
153+
? [filePath, '-o', path.join(tempDir, binName)]
152154
: ['c', 'cpp'].includes(runtime)
153-
? [filePath, '-o', path.join(tempDir, 'code'), '-I', workingDirectory]
155+
? [filePath, '-o', path.join(tempDir, binName), '-I', workingDirectory]
154156
: [];
155157

156158
const command = runtime === 'go' ? GO : runtime === 'rust' ? RUSTC : runtime === 'c' ? GCC : GPP;
@@ -209,11 +211,10 @@ async function executeInProcess(code, runtime, workingDirectory, processTimeout)
209211
if (!execKilled) {
210212
execKilled = true;
211213
clearTimeout(timeoutHandle);
212-
cleanup();
213214
if (execCode === 0 && ['rust', 'c', 'cpp'].includes(runtime)) {
214215
writeLog('stdout', execStdout);
215216
writeLog('stderr', execStderr);
216-
const exePath = path.join(tempDir, 'code');
217+
const exePath = path.join(tempDir, binName);
217218
const runChild = spawn(exePath, [], { cwd: workingDirectory, stdio: ['ignore', 'pipe', 'pipe'], timeout: processTimeout, detached: false });
218219
let runStdout = '';
219220
let runStderr = '';
@@ -272,6 +273,7 @@ async function executeInProcess(code, runtime, workingDirectory, processTimeout)
272273
}
273274
});
274275
} else {
276+
cleanup();
275277
resolve({ success: execCode === 0, exitCode: execCode ?? 1, stdout: execStdout, stderr: execStderr, error: null, logFile });
276278
}
277279
} else {

0 commit comments

Comments
 (0)