From 39462bc6b9ddd956beefc342d4e100b3b8587570 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 11 Apr 2025 20:24:24 +0100 Subject: [PATCH] chore: assign available port to env variable in dev suite (#12092) Previously when the port number was bumped up (eg `3001`) in our dev suite, HMR wouldn't work because it couldn't reliably read the new used port and it would default to `3000`. This assigns it properly to the env var and fixes that issues so HMR in our dev suite works on other ports too. Testing steps: - Have a local instance of dev suite running already on port 3000 - New repo run dev, it will bump to `3001` - Make any config change and you will see that HMR does not work without this fix --- test/dev.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/dev.ts b/test/dev.ts index 368ed124be..ca9629ced1 100644 --- a/test/dev.ts +++ b/test/dev.ts @@ -101,6 +101,10 @@ const port = process.env.PORT ? Number(process.env.PORT) : 3000 const availablePort = await findOpenPort(port) +// Assign the available port to process.env.PORT so that the next and our HMR server uses it +// @ts-expect-error - PORT is a string from somewhere +process.env.PORT = availablePort + // @ts-expect-error the same as in test/helpers/initPayloadE2E.ts const app = nextImport({ dev: true,