Skip to content

subprocess stdout PIPE unreadable on Windows 11 26200.8457 when parent process is a PyInstaller-packaged exe #5151

@lei1024976883

Description

@lei1024976883

Background:

This issue was originally discovered while using the Playwright Python library inside a PyInstaller-packaged application. Playwright communicates with its browser driver by spawning node.exe cli.js run-driver as a subprocess and exchanging messages over stdin/stdout pipes (length-prefixed JSON protocol).

The symptom was that async_playwright().start() would hang indefinitely — the Node.js process was visible in Task Manager, but never sent any response back to the Python parent process.

After isolating the issue, we confirmed it is not specific to Playwright's protocol, but a general problem: any Node.js subprocess spawned with stdout=PIPE from a PyInstaller-packaged Python exe returns empty stdout on this Windows build.

Description:
Environment:

Node.js: v24.14.1 (also tested with v20, same result)
OS: Windows 11 Pro 25H2, build 26200.8457 (Insider Preview)
Python: 3.13.13
PyInstaller: 6.13.0
Problem:

Image

When a PyInstaller-packaged Python exe spawns a Node.js subprocess with stdout=PIPE, the parent process receives empty bytes from the pipe. Node.js appears to start successfully (process is visible in Task Manager), but no data is written to stdout.

Image

The same code works correctly when:

Run directly as python script.py (not packaged)
The parent process redirects node's stdout to a file instead of a pipe
The child process is another Python exe (not Node.js)
Minimal reproduction:

Parent (Python, packaged with PyInstaller --onedir):

import subprocess, shutil
node = shutil.which("node")
proc = subprocess.Popen(
[node, "-e", "process.stdout.write('pong\n');"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdout, _ = proc.communicate(timeout=5)
print(repr(stdout)) # prints b'' instead of b'pong\n'
Key observations:

Parent process stdout handle type is FILE_TYPE_CHAR (console), confirmed via GetFileType
Node process starts and exits with returncode 0
stdout is empty (b''), not a timeout
Redirecting node stdout to a file works correctly — node writes the data
Python→Python subprocess pipe works correctly
Issue only occurs with Node.js as the child process in a PyInstaller-packaged parent
Issue is reproducible on Windows 11 build 26200.8457 but NOT on build 26200.8117
Hypothesis:

libuv's IOCP-based async pipe write may be incompatible with the anonymous pipe handle created by Python's subprocess.PIPE in this specific Windows build, causing written data to be lost before the read end can consume it.

Question:

Is there a known change in libuv's Windows pipe handling between Node v20 and v24, or a workaround to force synchronous pipe writes on Windows?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions