-
Notifications
You must be signed in to change notification settings - Fork 805
fix: show helpful error message when port is occupied #5146
Conversation
static/node/chain/chain.ethereum.js
Outdated
const { message, stack} = err; | ||
let {code} = err; | ||
// todo: we may be able to remove this check once https://github.com/trufflesuite/ganache/issues/4020 is resolved | ||
if (code === undefined && message && message.indexOf("listen EADDRINUSE") === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be > 0? If it's supposed to be 0, then perhaps use string.startsWith
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be string.startsWith
because the error message explicitly is listen EADDRINUSE: <reason>
- I'll change to that.
Thanks!
static/node/chain/chain.filecoin.js
Outdated
@@ -108,7 +108,16 @@ async function startServer(options) { | |||
try { | |||
await server.listen(options.port, options.hostname); | |||
} catch (err) { | |||
process.send({ type: "start-error", data: {code: err.code, stack: err.stack, message: err.message} }); | |||
const { message, stack} = err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { message, stack} = err; | |
const { message, stack } = err; |
static/node/chain/chain.filecoin.js
Outdated
@@ -108,7 +108,16 @@ async function startServer(options) { | |||
try { | |||
await server.listen(options.port, options.hostname); | |||
} catch (err) { | |||
process.send({ type: "start-error", data: {code: err.code, stack: err.stack, message: err.message} }); | |||
const { message, stack} = err; | |||
let {code} = err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let {code} = err; | |
let { code } = err; |
@@ -19,6 +19,7 @@ process.on("unhandledRejection", err => { | |||
|
|||
process.on("uncaughtException", err => { | |||
//console.log('uncaught exception:', err.stack || err) | |||
// hilariously EADDRINUSE errors will get raised here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// hilariously EADDRINUSE errors will get raised here | |
// hilariously, EADDRINUSE errors will get raised here |
static/node/chain/chain.ethereum.js
Outdated
@@ -108,9 +108,16 @@ async function startServer(options) { | |||
try { | |||
await server.listen(options.port, options.hostname); | |||
} catch (err) { | |||
const { message, stack} = err; | |||
let {code} = err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let {code} = err; | |
let { code } = err; |
static/node/chain/chain.ethereum.js
Outdated
@@ -108,9 +108,16 @@ async function startServer(options) { | |||
try { | |||
await server.listen(options.port, options.hostname); | |||
} catch (err) { | |||
const { message, stack} = err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { message, stack} = err; | |
const { message, stack } = err; |
@davidmurdoch @cds-amal I've made those changes, and merged, just because I wanted to incorporate into the github actions branch. If you have any more concerns, I'm happy to fix them up. |
No description provided.