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

Aborting command execution on demand? #1914

Open
slavafomin opened this issue Sep 7, 2024 · 1 comment
Open

Aborting command execution on demand? #1914

slavafomin opened this issue Sep 7, 2024 · 1 comment

Comments

@slavafomin
Copy link

slavafomin commented Sep 7, 2024

Hello!

Thank you for this great library!

However, I can't find a way to abort the pending command execution. For example: I'm using XREAD BLOCK 60000 … (XREAD) command to listen for Redis stream. It blocks execution for e.g. 60 seconds. What if I need to stop this command and abort it in the middle? E.g. when I receive a signal from the OS to terminate the process or something.

It should either return the "Cancelable Promise" or accept an AbortSignal. Am I missing something or is it not implemented yet?

Thanks!

@slavafomin
Copy link
Author

slavafomin commented Sep 9, 2024

I hope someone would find this helpful: what I've found out (the hard way) is that blocking connections (like XREAD BLOCK) should be executed by it's own instance of ioredis, because the library won't create a new connection for you, you must do this manually. Otherwise your blocking command could block the other parts of your application that relies on Redis.

Then, you can use the Redis.disconnect() method to terminate such blocking commands (do not use quit()).

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

No branches or pull requests

1 participant