Skip to content

fix: drain wp db import stdout to prevent restore deadlock#25

Merged
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:fix/db-restore-stdout-deadlock
Jun 7, 2026
Merged

fix: drain wp db import stdout to prevent restore deadlock#25
kjellberg merged 1 commit into
kiqr:mainfrom
kjellbergzoey:fix/db-restore-stdout-deadlock

Conversation

@kjellbergzoey

Copy link
Copy Markdown
Contributor

Problem

src/commands/db/restore.tsx spawns wp db import - via spawnWpCli, which uses stdio: ['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 docker child; 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

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>
@kjellberg
kjellberg merged commit 5d9be71 into kiqr:main Jun 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants