open-cli-tools / open-cli-tools/concurrently

Script startup freezes: `concurrently` + `mysql2` + `tsx watch`

Open
#525 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

pull request welcome
Dominant language
TypeScript
Stars
7.9k
Forks
281
Avg merge
17h 12m
Merged PRs (30d)
1

Description

Brief

Following setup freezes:

concurrently "vite" "tsx watch index.ts"

index.ts

console.log("hello world");
import "mysql2"

hello world does not log before app freezes.

Works:

# terminal 1:
vite
# terminal 2:
tsx watch index.ts

Or:

index.ts

console.log("hello world");
// import "mysql2"

Detailed Explanation

I was using concurrently with the mysql2 package, with tsx watch to run my code and watch for changes. At some point, it started freezing completely on startup. I even added a console.log at the very beginning of the entry point script that would not even print, which made me think it was an import issue (since I think imports run even before that console.log).

After disabling various parts of code, I finally disabled my import for mysql2 and it started running again. But, even if I did not use the value imported, just having the import "mysql2" by itself would cause it to freeze.

Finally, I tried running the two-part application without concurrently and just in separate terminals, and it worked fine, with the mysql2 import and everything.

I presume this is an issue with concurrently, mysql2, and tsx watch since it works fine if I remove any one of these three dependents (using tsx not in watch mode also works). I switched to npm-run-all and it works fine now. Not sure exactly what mysql2 is doing as a side-effect, or what breaks it when using concurrently.

Environment

OS: Windows 10 x64
Terminal: Powershell integrated in VSCode 1.96.2

Minimal Example

I've reproduced this issue with two files:

  1. The following minimal package.json:
{
  "name": "test",
  "version": "0.0.1",
  "scripts": {
    "dev": "concurrently \"vite\" \"tsx watch index.ts\"",
    "dev-nowatch": "concurrently \"vite\" \"tsx index.ts\"",
    "dev-index": "tsx watch index.ts"
  },
  "dependencies": {
    "mysql2": "^3.12.0"
  },
  "devDependencies": {
    "concurrently": "^9.1.2",
    "tsx": "^4.19.2",
    "typescript": "~5.6.2",
    "vite": "^6.0.5"
  }
}
  1. The following file, index.ts:
console.log("hello world");
import "mysql2";

With these files, run:

npm i

The following shows that hello world does not log as expected:

npm run dev

The following commands show that it does print when not using concurrently or when not using watch mode:

npm run dev-nowatch
npm run dev-index

Also try commenting out import "mysql2" to see that this also works:

console.log("hello world");
// import "mysql2"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal package.json scripts and index.ts reproduction, then run npm run dev, npm run dev-nowatch, and npm run dev-index on the stated Windows environment. Compare startup behavior with and without import "mysql2"; done means the concurrently command logs "hello world" while retaining watch mode and the mysql2 import.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, typescript, vite
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.