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

Wrong timeToExpire unit #1167

Closed
AntunVukicevic opened this issue Mar 13, 2023 · 2 comments
Closed

Wrong timeToExpire unit #1167

AntunVukicevic opened this issue Mar 13, 2023 · 2 comments

Comments

@AntunVukicevic
Copy link

timeToExpire value returned from the increment function is in milliseconds instead of seconds. Because of that NestJs ThrottlerGuard sets the wrong Retry-After header in the HTTP response when the throttling limit is hit.

From the quick debug session, it looks like calling the PTTL Redis command returns milliseconds that are not converted to seconds afterwards.

@slavafomin
Copy link

slavafomin commented May 12, 2023

I can confirm this issue. The content of the Retry-After header is incorrect. It should contain seconds, while in practice it contains milliseconds. I think we should convert millis to seconds here right before we return the result to the guard.

@kkoomen
Copy link
Owner

kkoomen commented May 13, 2023

Hi. Thanks a lot for noticing this, unfortunately this became a problem during the big rewrite last time. The tests did check for a number, but not a specific number. I've modified tests to make sure the secs are beings checked to make sure this won't happen again in the future.

I've just released this immediately under v0.3.2 on NPM.

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

3 participants