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

feat: port in use #6887

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
52 changes: 32 additions & 20 deletions src/commands/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,39 @@ import { createWatchCommand } from './watch/index.js'

const SUGGESTION_TIMEOUT = 1e4

process.on('uncaughtException', async (err) => {
process.on('uncaughtException', async (err: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a proper type here rather than adding in an any

console.log('')
error(
`${chalk.red(
'Netlify CLI has terminated unexpectedly',
)}\nThis is a problem with the Netlify CLI, not with your application.\nIf you recently updated the CLI, consider reverting to an older version by running:\n\n${chalk.bold(
'npm install -g netlify-cli@VERSION',
)}\n\nYou can use any version from ${chalk.underline(
'https://ntl.fyi/cli-versions',
)}.\n\nPlease report this problem at ${chalk.underline(
'https://ntl.fyi/cli-error',
)} including the error details below.\n`,
{ exit: false },
)

const systemInfo = await getSystemInfo()

console.log(chalk.dim(err.stack || err))
console.log(chalk.dim(systemInfo))

reportError(err, { severity: 'error' })

if (err.code === 'EADDRINUSE') {
error(
`${chalk.red(`Port ${err.port} is already in use`)}\n\n` +
`This could be due to one of your serverless functions initializing a server\n` +
`to listen on port ${err.port} without properly closing it.\n\n` +
`To resolve this issue, try the following:\n` +
`1. Check if any other applications are using port ${err.port}\n` +
`2. Review your serverless functions for any lingering server connections\n`,
{ exit: false },
)
} else {
error(
`${chalk.red(
'Netlify CLI has terminated unexpectedly',
)}\nThis is a problem with the Netlify CLI, not with your application.\nIf you recently updated the CLI, consider reverting to an older version by running:\n\n${chalk.bold(
'npm install -g netlify-cli@VERSION',
)}\n\nYou can use any version from ${chalk.underline(
'https://ntl.fyi/cli-versions',
)}.\n\nPlease report this problem at ${chalk.underline(
'https://ntl.fyi/cli-error',
)} including the error details below.\n`,
{ exit: false },
)

const systemInfo = await getSystemInfo()

console.log(chalk.dim(err.stack || err))
console.log(chalk.dim(systemInfo))
reportError(err, { severity: 'error' })
}

process.exit(1)
})
Expand Down