TobiasMelen / next-dev-https

Next Development server Https/QR support
MIT License
25 stars 4 forks source link

TypeError: process.stdin.setRawMode is not a function #1

Closed emulienfou closed 1 year ago

emulienfou commented 1 year ago

Hi there, I have a monorepo that runs multiple Next.js project using concurrently.

When you "hijack" stdin to print the QR code with the param --qr this generate the next error in all the next project:

TypeError: process.stdin.setRawMode is not a function
[2]     at /home/.../app/node_modules/next-dev-https/src/server.js:175:23
[2] yarn dev:app1 exited with code 1

To reproduce the issue, add the next scripts in your pacakge.json:

"scripts": {
    "dev:all": "concurrently \"yarn dev:app1\" \"yarn dev:app2\"",
    "dev:app": "yarn workspace app1 dev",
    "dev:app": "yarn workspace app2 dev"
}

In app1 dev script is running the command: next-dev-https --https --qr --port 4430 while app2 is running next-dev-https --https --qr --port 4431

No issues if I remove the --qr parameters!

TobiasMelen commented 1 year ago

Hi @emulienfou Thanks for reporting the issue, and sorry for the late reply. Unfortunately I haven't really set aside much time or thought to maintaining this package. Great point that the --qr option probably does not work all that well if the server is run as any type of sub task. I'm thinking that this should probably just be better documented and throw a more descriptive error. But to get a better understanding of your problem: What would be the ideal case for your example, would you like two QR codes to be printed to the terminal?

TobiasMelen commented 1 year ago

I've released patch version 0.1.2 which not only checks stdin for isTTY() but now also verifies that setRawMode is an actual function. The functionality for the --qr parameter will be that the QR code is printed once, and it's not possible to show it again except for restarting the server. Hopefully this is ok for your use-case, comment here otherwise and i'll reopen the issue.

emulienfou commented 1 year ago

Thanks @TobiasMelen fir the fix!