Coder Social home page Coder Social logo

Comments (6)

junegunn avatar junegunn commented on July 17, 2024 1

Thanks for the repro. I can reproduce the problem, and it definitely looks like nodemon is trying to read user input. So nodemon and fzf are both competing to read from /dev/tty at the same time, and it causes the problems.

Workaround 1. Prevent nodemon from reading user input

By redirecting /dev/null to its standard input.

node_modules/nodemon/bin/nodemon.js index.js < /dev/null | fzf --ansi --tail 10000 --tac

The problem is nodemon doesn't terminate after fzf exits.

Workaround 2. Make fzf start the process

fzf --ansi --tail 10000 --tac --bind 'start:reload:node_modules/nodemon/bin/nodemon.js index.js'

fzf starts nodemon process when it starts, and can terminate it when it exits.

(Works better with 5b52833)

from fzf.

junegunn avatar junegunn commented on July 17, 2024

Does node_modules/.bin/ts-node src/index.ts take user input from keyboard?

fzf crashes

Are there any error messages?

from fzf.

hboon avatar hboon commented on July 17, 2024

Does node_modules/.bin/ts-node src/index.ts take user input from keyboard?

No.

Are there any error messages?

No. So, at a loss what to do to debug. I could run the GitHub version again if there's a way to enable logging somewhere.

from fzf.

junegunn avatar junegunn commented on July 17, 2024

Can you provide minimal steps to reproduce the problem from my side? I don't have your project with index.ts so there's no way I can further look into the problem. Also, please don't assume that I know anything about the thing called "ts-node".

from fzf.

hboon avatar hboon commented on July 17, 2024

Ah, sorry, I was hoping to look for a way to get debug logs so I can gather more information first. Thanks for helping to look into this.

I was wrong, it wasn't ts-node, but nodemon which reproduces the issue. From the tool's README:

Monitor for any changes in your node.js application and automatically restart the server - perfect for development

I made a repo to reproduce the issue for me — https://github.com/hboon/nodemon-fzf/. It's really just running nodemon or a single source file that logs 1 line to STDOUT. There are 2 branches. (B) should be easier to get started (but trust…).

A. main — you will need to have pnpm installed and run pnpm i first to install the nodemon that is causing this)
B. with-node-modules — this includes nodemon already so you can skip (A), and don't need to install pnpm

Run this:

node_modules/nodemon/bin/nodemon.js index.js | fzf

index.js only logs a line to STDOUT so I suppose it's the way nodemon works that's causing an issue?

I'm hoping to use fzf for streaming server logs during development.

from fzf.

hboon avatar hboon commented on July 17, 2024

Both workarounds work for me. I'll use (2). Doesn't seem like 5b52833 is needed yet.

But all good. Thanks again!

from fzf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.