trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

EADDRINUSE error is uncoded, most of the time #4020

Closed jeffsmale90 closed 1 year ago

jeffsmale90 commented 1 year ago

Occupying the port defined by server.port results in an error:

{
  code: undefined,
  message: 'listen EADDRINUSE: address already in use 127.0.0.1:5001'
}

Whereas occupying the port defined by chain.ipfsport (with flavor:filecoin) results in an error:

{
  code: 'EADDRINUSE',
  message: 'listen EADDRINUSE: address already in use 127.0.0.1:5001'
}

Reproduced with Ganache 7.5.0 and @ganache/filecoin 0.1.5

const g = require("ganache");

const handler = (e) => {
  console.error({
    code: e.code,
    message: e.message,
  });
  process.exit(1);
};

const options = {
  flavor: "filecoin",
  server: { port: 8545, host: "127.0.0.1" },
  chain: { ipfsPort: 5001 },
};

g.server(options)
  .listen(options.server.port, options.server.host)
  .catch(handler);
davidmurdoch commented 1 year ago

Oops! I think this complication comes from the fact that we use uWS and "translate" its error to the form of listen EADDRINUSE: address already in use. This was likely just an oversight.