From a01b1e7b5cf163c518d90d8b2d927ef9882e08d4 Mon Sep 17 00:00:00 2001 From: kjellbergzoey Date: Sun, 7 Jun 2026 17:15:47 +0000 Subject: [PATCH] fix: drain wp db import stdout to prevent restore deadlock 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 --- src/commands/db/restore.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/commands/db/restore.tsx b/src/commands/db/restore.tsx index 4ded4c5..21d37cb 100644 --- a/src/commands/db/restore.tsx +++ b/src/commands/db/restore.tsx @@ -79,6 +79,10 @@ async function runRestore( const child = spawnWpCli(composePath, ['wp', 'db', 'import', '-']); const stderrChunks: Buffer[] = []; child.stderr.on('data', (c: Buffer) => stderrChunks.push(c)); + // Drain stdout. We don't use its content (errors come from stderr), but if + // the child writes more than the OS pipe buffer (~64KB) and nothing reads + // it, the child blocks on write and the import deadlocks. + child.stdout.resume(); const src = storage.openRead(record).pipe(createGunzip()); src.pipe(child.stdin); await new Promise((resolve, reject) => {