Skip to content

Sandboxed PHP subprocesses may truncate stdout and stderr #4166

Description

@chubes4

Problem

The sandboxed PHP spawn handler starts piping child stdout and stderr, then calls processApi.exit() after result.exitCode without awaiting either pipeTo() promise. A sufficiently large child response can therefore close the parent-facing streams before their tails are delivered.

This was reproduced with a PHPUnit subprocess that completed 693/695 tests but lost its final test and summary output. A focused 1 MiB subprocess probe verifies the generic contract.

Root cause

In packages/php-wasm/universal/src/lib/sandboxed-spawn-handler-factory.ts, the PHP branch creates stdout/stderr pipeTo() promises but does not await them before processApi.exit().

Acceptance criteria

  • The PHP subprocess exit status is retained.
  • Both stdout and stderr are fully drained before the parent-facing process exits.
  • A large-output regression verifies the final tail bytes in Asyncify and JSPI.

Related, already tracked

Bare child php also needs stdin forwarded into PHP.cli(). That owning API gap is already tracked by #3519 and implemented in open PR #3523; it is intentionally outside this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions