Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6687 EADDRINUSE #6808

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quick-dingos-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': minor
HarunOr marked this conversation as resolved.
Show resolved Hide resolved
---

Fixes a non-critical bug where an EADDRINUSE error was thrown when running next dev
20 changes: 9 additions & 11 deletions packages/keystone/src/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down