From 61146aacaffa24772b1c2107ef623f2ab202141c Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 19 Jul 2023 14:38:52 +0100 Subject: [PATCH] fix(test-utils): pass along error if server can't start (#22216) --- packages/test-utils/src/server.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/test-utils/src/server.ts b/packages/test-utils/src/server.ts index 99c55e60b4..01e51cd946 100644 --- a/packages/test-utils/src/server.ts +++ b/packages/test-utils/src/server.ts @@ -28,6 +28,7 @@ export async function startServer () { } }) await waitForPort(port, { retries: 32 }) + let lastError for (let i = 0; i < 50; i++) { await new Promise(resolve => setTimeout(resolve, 100)) try { @@ -35,10 +36,12 @@ export async function startServer () { if (!res.includes('__NUXT_LOADING__')) { return } - } catch {} + } catch (e) { + lastError = e + } } ctx.serverProcess.kill() - throw new Error('Timeout waiting for dev server!') + throw lastError || new Error('Timeout waiting for dev server!') } else { ctx.serverProcess = execa('node', [ resolve(ctx.nuxt!.options.nitro.output!.dir!, 'server/index.mjs')