fix: drain wp db import stdout to prevent restore deadlock#25
Merged
Merged
Conversation
src/commands/db/restore.tsx spawned `wp db import -` with stdio ['pipe','pipe','pipe'] but never read the child's stdout. If the child writes more than the OS pipe buffer (~64KB) and nothing drains it, the child blocks on write and the restore deadlocks. (The dump path already consumes the child's stdout stream.) Restore only surfaces stderr; stdout content is not used, so drain it via `child.stdout.resume()`. Error handling is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
src/commands/db/restore.tsxspawnswp db import -viaspawnWpCli, which usesstdio: ['pipe', 'pipe', 'pipe'], but it never reads or drains the child's stdout. If the child writes more than the OS pipe buffer (~64KB) and nothing consumes it, the child blocks on write and the restore deadlocks.By contrast, the dump path consumes the child's stdout (
child.stdout.pipe(createGzip())), so it never hits this.Fix
Restore only surfaces stderr (that's what the error message is built from); the child's stdout content is not used. So we drain it with
child.stdout.resume(), which puts the stream into flowing mode and discards the data, keeping the pipe buffer empty. Error handling and the close/error promise wiring are unchanged.Tests
The restore flow lives inside an Ink component and spawns a real
dockerchild; there is no existing harness to unit-test that spawn wiring without substantial mocking, so no brittle test was added. All existing tests pass (192).Gates
npm run typecheck✅npm test✅ (192 passed)npm run build✅npm run lint✅🤖 Generated with Claude Code