Переглянути джерело

fix(subprocess): create control carriers for overlapped Windows I/O

Tianyi Cui 2 тижнів тому
батько
коміт
83a45679df

+ 2 - 2
packages/subprocess/subprocess-local/src/runner-launch.ts

@@ -129,7 +129,7 @@ export function runnerStdio(
   if (!ipc) {
     if (spec.stdio.control === 'pipe') {
       while (targetStdio.length < SUBPROCESS_CONTROL_FD) targetStdio.push('ignore')
-      targetStdio.push('pipe')
+      targetStdio.push('overlapped')
     }
     return targetStdio
   }
@@ -142,7 +142,7 @@ export function runnerStdio(
     spec.stdio.stdout === 'inherit' ? 1 : 'pipe',
     spec.stdio.stderr === 'inherit' ? 2 : 'pipe',
   ]
-  if (spec.stdio.control === 'pipe') runner.push('pipe')
+  if (spec.stdio.control === 'pipe') runner.push('overlapped')
   return runner
 }
 

+ 1 - 1
packages/subprocess/subprocess-local/src/spawn.ts

@@ -657,7 +657,7 @@ export function spawnSubprocess(spec: SubprocessSpawnSpec, internals: SpawnInter
   ]
   if (spec.stdio.control === 'pipe') {
     while (stdio.length < SUBPROCESS_CONTROL_FD) stdio.push('ignore')
-    stdio.push('pipe')
+    stdio.push('overlapped')
   }
   const child = (internals.spawn ?? spawn)(program as string, args, {
     cwd: spec.cwd,

+ 3 - 0
packages/subprocess/subprocess-local/tests/spawn-runner.spec.ts

@@ -274,6 +274,9 @@ describe('runner launch inputs', () => {
     expect(parseRunnerTargetArgv(['--', 'node', 'a'])).toEqual(['node', 'a'])
     expect(() => parseRunnerTargetArgv(['node'])).toThrow('private -- delimiter')
     expect(runnerStdio(spec, false)).toEqual(['pipe', 'pipe', 'inherit'])
+    const withControl = { ...spec, stdio: { ...spec.stdio, control: 'pipe' as const } }
+    expect(runnerStdio(withControl, false)).toEqual(['pipe', 'pipe', 'inherit', 'ignore', 'ignore', 'ignore', 'ignore', 'overlapped'])
+    expect(runnerStdio(withControl, true)).toEqual(['ignore', 'ignore', 'ignore', 'ipc', 'pipe', 'pipe', 2, 'overlapped'])
     expect(runnerStdio(spec, true)).toEqual([
       'ignore', 'ignore', 'ignore', 'ipc', 'pipe', 'pipe', 2,
     ])