From cd4c4abb2127f7ebadc6bae77e288106123db858 Mon Sep 17 00:00:00 2001 From: Harun Oral Date: Sun, 24 Oct 2021 04:25:09 +0200 Subject: [PATCH 1/3] Fix EADDRINUSE Fixes a bug where an EADDRINUSE error was thrown when running next dev. --- packages/keystone/src/next.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/keystone/src/next.ts b/packages/keystone/src/next.ts index 701814afbb3..c0d23d518b7 100644 --- a/packages/keystone/src/next.ts +++ b/packages/keystone/src/next.ts @@ -14,27 +14,25 @@ export const withKeystone = | 'phase-development-server', thing: any ) => { + const cliPath = require.resolve('@keystone-next/keystone/bin/cli.js'); + if (phase === 'phase-production-build') { - execa.sync('node', [require.resolve('@keystone-next/keystone/bin/cli.js'), 'postinstall'], { + execa.sync('node', [cliPath, 'postinstall'], { stdio: 'inherit', }); } + if (phase === 'phase-development-server' && !hasAlreadyStarted) { hasAlreadyStarted = true; - const cliPath = require.resolve('@keystone-next/keystone/bin/cli.js'); - execa.sync('node', [cliPath, 'postinstall', '--fix'], { stdio: 'inherit', }); - // for some reason things blow up with EADDRINUSE if the dev call happens synchronously here - // so we wait a sec and then do it - setTimeout(() => { - execa('node', [cliPath], { - stdio: 'inherit', - env: { ...process.env, PORT: process.env.PORT || '8000' }, - }); - }, 100); + + execa('node', [cliPath], { + stdio: 'inherit', + env: { ...process.env, PORT: process.env.PORT || '8000' }, + }); } let internalConfigObj = typeof internalConfig === 'function' ? internalConfig(phase, thing) : internalConfig; From 150bfeee7aeed9aeb619c49bdb3356a54b4c5814 Mon Sep 17 00:00:00 2001 From: Harun Oral Date: Sun, 24 Oct 2021 04:57:09 +0200 Subject: [PATCH 2/3] added changeset --- .changeset/quick-dingos-shave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/quick-dingos-shave.md diff --git a/.changeset/quick-dingos-shave.md b/.changeset/quick-dingos-shave.md new file mode 100644 index 00000000000..14b2608b251 --- /dev/null +++ b/.changeset/quick-dingos-shave.md @@ -0,0 +1,5 @@ +--- +'@keystone-next/keystone': minor +--- + +Fixes a non-critical bug where an EADDRINUSE error was thrown when running next dev From cc6528bcd88e9288085fcaa3fae9ff71dea78af4 Mon Sep 17 00:00:00 2001 From: Harun Oral Date: Sun, 24 Oct 2021 05:14:35 +0200 Subject: [PATCH 3/3] Update .changeset/quick-dingos-shave.md Co-authored-by: Daniel Cousens <413395+dcousens@users.noreply.github.com> --- .changeset/quick-dingos-shave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/quick-dingos-shave.md b/.changeset/quick-dingos-shave.md index 14b2608b251..659e92a3a60 100644 --- a/.changeset/quick-dingos-shave.md +++ b/.changeset/quick-dingos-shave.md @@ -1,5 +1,5 @@ --- -'@keystone-next/keystone': minor +'@keystone-next/keystone': patch --- Fixes a non-critical bug where an EADDRINUSE error was thrown when running next dev