Skip to content

Commit 39462bc

Browse files
authored
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
1 parent 3a7cd71 commit 39462bc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/dev.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ const port = process.env.PORT ? Number(process.env.PORT) : 3000
101101

102102
const availablePort = await findOpenPort(port)
103103

104+
// Assign the available port to process.env.PORT so that the next and our HMR server uses it
105+
// @ts-expect-error - PORT is a string from somewhere
106+
process.env.PORT = availablePort
107+
104108
// @ts-expect-error the same as in test/helpers/initPayloadE2E.ts
105109
const app = nextImport({
106110
dev: true,

0 commit comments

Comments
 (0)