tsx icon indicating copy to clipboard operation
tsx copied to clipboard

watch mode breaks stdout / piping

Open Nicholaiii opened this issue 2 years ago • 6 comments

Bug description

When using watch mode, piping stdout is broken, it doesn't do anything at all, just prints straight to console. It works without watch.

  • Before image
  • After (screen is cleared) image

Reproduction

I can't do this without dependencies, ultimately my example is piping into one.

Environment

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
    Memory: 1.12 GB / 15.37 GB
  Binaries:
    Node: 18.8.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.2.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    tsx: ^3.12.2 => 3.12.2

Can you work on a fix?

  • [ ] I’m interested in opening a pull request to address this issue.

Nicholaiii avatar Feb 04 '23 19:02 Nicholaiii

I can't do this without dependencies, ultimately my example is piping into one.

That's fine if you can strip it down to bare minimums. Please provide a link to a minimal reproduction repository.

privatenumber avatar Feb 04 '23 23:02 privatenumber

https://github.com/Nicholaiii/tsx-pipe

I am now only getting this issue on the first log line. I have no idea what (if anything) changed. npm run normal (works immediately) npm run watch (works after first log)

Nicholaiii avatar Feb 05 '23 14:02 Nicholaiii

Same thing is happening when using concurrently to run tsx watch, no console output at all.

piotrek-szczygiel avatar Apr 17 '23 23:04 piotrek-szczygiel

@piotrek-szczygiel

Thanks for your comment! But, with the limited info provided, I'm not sure if it's relevant to this thread, so I'm gonna hide it for now.

If you can share more details and steps to reproduce in a new Issue, that would be super helpful. Thanks, and let me know if you need any help.

privatenumber avatar Apr 17 '23 23:04 privatenumber

@privatenumber I have the same problem too

I run npx tsx watch src/intex.ts | jg but the output from the program isn't parsable by jq and I get parse error: Invalid numeric literal at line 1, column 3

If I run npx tsx src/intex.ts | jg it works just fine.

src/index.ts can be as simple as:

console.log(`{"message": "Hello World!"}`)

torbjornvatn avatar May 03 '23 05:05 torbjornvatn

Gotcha, thanks for the repro. Happy to accept a PR.

privatenumber avatar May 03 '23 12:05 privatenumber

Same thing is happening when using concurrently to run tsx watch, no console output at all.

Same thing for me, this is the only reason I cant switch from ts-node.

hornta avatar Jan 09 '24 21:01 hornta