nodemon: Can't use bash history after SIGINT with Yarn

  • nodemon -v: 2.0.1
  • node -v: v12.13.0
  • Operating system/terminal environment: Linux 4.19.85-1-MANJARO x86_64
  • Using Docker? What image: No
  • Command you ran: yarn start

…with package.json configured as:

{
  "scripts": { "start": "nodemon" },
  "nodemonConfig": {
    "watch": ["src"],
    "ext": "ts",
    "ignore": [],
    "exec": "ts-node ./src --env=development"
  },
  "dependencies": {
    "express": "^4.17.1"
  },
  "devDependencies": {
    "@types/express": "^4.17.2",
    "ts-node": "^8.5.4",
    "typescript": "^3.7.3"
  }
}

Expected behaviour

After using CTRL+C to stop nodemon, I should be able to use my up and down keyboard arrows to navigate bash history.

Actual behaviour

Instead, after using CTRL+C and pressing the up arrow key, my console prints ^[[A. (If I hit the down arrow key, it prints ^[[B.) After I press CTRL+C a second time, I am able to navigate bash history.

However, if I don’t press CTRL+C a second time I am still able to manually type the command yarn start to start again.

Also, the first time CTRL+C is used, my shell prints out ^C once and produces a new prompt (where up/down doesn’t work). Then the second time I press CTRL+C to fully exit, my shell prints out ^C^C instead of just one ^C.

Steps to reproduce

  1. Use yarn to run nodemon with the configuration presented above.

More information

  • Running nodemon with the --dump flag produced no new output.
  • This problem does not happen if I use npm run start instead of yarn start so I’m assuming it is a similar problem to #1326 .

My program

import express from "express";

const app = express();
const port = 4081;
app.get("/", (req, res) => {
  res.send("Hello from TypeScript!");
});
app.listen(port, err => {
  if (err) {
    return console.error(err);
  }
  return console.log(`server is listening on http://localhost:${port}`);
});

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 18 (4 by maintainers)

Most upvoted comments

I was able to re-create this (windows - wsl) and this is what I was able to determine in the time I had.

This issue is triggering the quit path. run.js is emitting the quit event with code 130. This is resulting in the bus.on('quit') event being fired and the kill(child, 'SIGINT') being called, calling into the exit method which does funnel down to the process.exist(code).

With yarn, the terminal acts as if the standard in as been released but has not completed executing code. Adding in logs (could not get the debug logs to run at the time) can show this clearly in the console (as shown below). This does not occur within npm and just executes all and exists.

image

I did not have much time to investigate but hope this helps.