Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running tldr with a non-existent topic or doing an update causes long freezes #441

Open
sdondley opened this issue Jul 23, 2024 · 7 comments
Labels

Comments

@sdondley
Copy link

I'm on alpine, installed with npm. If I do tldr blah I see something like this:

✔ Updating...
⠼ Creating index...

It just hangs for like two minutes. Same thing happens when tldr --update is run.

@kbdharun kbdharun transferred this issue from tldr-pages/tldr Jul 23, 2024
@kbdharun kbdharun added the bug label Jul 23, 2024
@agnivade
Copy link
Member

Yes, this is due to the single threaded nature of tldr. We try to yield in intervals but it's difficult to make the spinner run more smoothly. But it's just due to the addition of the spinner that you "feel" it's stuck. It's just creating the index.

Is there a real bug that you wanted to report?

@sdondley
Copy link
Author

So you're saying it's not a bug that if I make a typo or type in a non-existent document I have to open a new terminal shell and or wait two minutes for the program to re-index everything? This isn't just a "feeling" I have. 2 minutes is a long time for the command line to lockup and do nothing.

@agnivade
Copy link
Member

Sorry I realize that my earlier post came across as snarky. Wasn't my intention.

if I make a typo or type in a non-existent document I have to open a new terminal shell and or wait two minutes for the program to re-index everything?

You could just cancel the re-indexing. You don't need to wait. The fact that we decide to re-populate the cache if a command isn't found was a design decision based on the fact that the newly entered command might exist in the remote repo, but not in the local cache.

We could, technically add an escape hatch to prevent this behavior. I am open to it. But the core issue here is that indexing takes some time and freezes the UI. And that's not a bug. It's just due to the single threaded design of node.js. I am sure it can be improved. PRs would be most welcome.

@spageektti
Copy link
Member

What about re-indexing only if page exists in the remote repo (ping https://raw.githubusercontent.com/tldr-pages/tldr/main/pages.xx/platform/page.md)?

@agnivade
Copy link
Member

Sure, a reasonable approach.

@kbdharun
Copy link
Member

We have been providing a pre-built index for a while upstream at https://github.com/tldr-pages/tldr/releases/latest/download/index.json, would it be possible for the Node client to be adapted to use it?

@agnivade
Copy link
Member

The client builds its own search index. There's some logic here: https://github.com/tldr-pages/tldr-node-client/blob/main/lib/search.js. Unless we pre-build this entire logic, it might be difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants