Skip to content

Commit 7cdae55

Browse files
authored
Merge pull request #965 from web3dev1337/fix/windows-pty-conpty-mismatch
fix(windows): patch node-pty startProcess arg mismatch
2 parents 51bc725 + bbd6921 commit 7cdae55

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

scripts/tauri/prepare-backend-resources.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,25 @@ function main() {
412412
}
413413
}
414414

415+
// Patch node-pty windowsPtyAgent.js: the JS wrapper passes 7 args to
416+
// conptyNative.startProcess() but the native conpty.node only accepts 6.
417+
// Remove the 7th arg (useConptyDll) to fix PTY spawn on Windows.
418+
const ptyAgentPath = path.join(nodeModulesPath, 'node-pty', 'lib', 'windowsPtyAgent.js');
419+
if (fs.existsSync(ptyAgentPath)) {
420+
let ptyAgent = fs.readFileSync(ptyAgentPath, 'utf8');
421+
const broken = 'conptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor, this._useConptyDll)';
422+
const fixed = 'conptyNative.startProcess(file, cols, rows, debug, this._generatePipeName(), conptyInheritCursor)';
423+
if (ptyAgent.includes(broken)) {
424+
ptyAgent = ptyAgent.replace(broken, fixed);
425+
fs.writeFileSync(ptyAgentPath, ptyAgent);
426+
console.log('[tauri] Patched node-pty windowsPtyAgent.js (removed useConptyDll arg)');
427+
} else if (ptyAgent.includes(fixed)) {
428+
console.log('[tauri] node-pty windowsPtyAgent.js already patched');
429+
} else {
430+
console.warn('[tauri] WARNING: Could not find expected startProcess call in windowsPtyAgent.js — PTY may fail on Windows');
431+
}
432+
}
433+
415434
const marker = path.join(outDir, 'server', 'index.js');
416435
if (!fs.existsSync(marker)) {
417436
throw new Error(`Expected backend entry not found: ${marker}`);

0 commit comments

Comments
 (0)