diff --git a/.changeset/quiet-masks-lay.md b/.changeset/quiet-masks-lay.md new file mode 100644 index 0000000000..13013dc9da --- /dev/null +++ b/.changeset/quiet-masks-lay.md @@ -0,0 +1,5 @@ +--- +'@shopify/cli-hydrogen': patch +--- + +Fix an issue where the local worker runtime could freeze after a number of requests. diff --git a/packages/cli/src/lib/mini-oxygen/workerd.ts b/packages/cli/src/lib/mini-oxygen/workerd.ts index c716afeba6..3c4d632af1 100644 --- a/packages/cli/src/lib/mini-oxygen/workerd.ts +++ b/packages/cli/src/lib/mini-oxygen/workerd.ts @@ -92,8 +92,16 @@ export async function startWorkerdServer({ log: new NoOpLog(), liveReload: watch, host: 'localhost', - handleRuntimeStdio() { + handleRuntimeStdio(stdout, stderr) { // TODO: handle runtime stdio and remove inspector logs + // stdout.pipe(process.stdout); + // stderr.pipe(process.stderr); + + // Destroy these streams to prevent memory leaks + // until we start piping them to the terminal. + // https://github.com/Shopify/hydrogen/issues/1720 + stdout.destroy(); + stderr.destroy(); }, workers: [ { diff --git a/packages/cli/src/lib/vite/mini-oxygen.ts b/packages/cli/src/lib/vite/mini-oxygen.ts index c6bde34be2..7f3e15d703 100644 --- a/packages/cli/src/lib/vite/mini-oxygen.ts +++ b/packages/cli/src/lib/vite/mini-oxygen.ts @@ -60,6 +60,14 @@ export async function startMiniOxygenRuntime({ inspectorPort: privateInspectorPort, handleRuntimeStdio(stdout, stderr) { // TODO: handle runtime stdio and remove inspector logs + // stdout.pipe(process.stdout); + // stderr.pipe(process.stderr); + + // Destroy these streams to prevent memory leaks + // until we start piping them to the terminal. + // https://github.com/Shopify/hydrogen/issues/1720 + stdout.destroy(); + stderr.destroy(); }, workers: [ {