Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants