WordPress / WordPress/wordpress-playground

Sandboxed PHP subprocesses may truncate stdout and stderr

Open
#4,166 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2k
Forks
462
Avg merge
18h 44m
Merged PRs (30d)
33

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/php-wasm/universal/src/lib/sandboxed-spawn-handler-factory.ts and trace the PHP branch's stdout and stderr pipeTo promises through processApi.exit(). Use the focused 1 MiB subprocess probe as the regression model; done means the exit status is retained, both streams are drained, and final tail bytes are verified in both Asyncify and JSPI.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, typescript, wasm
Domain
backend, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.