oxidecomputer / third-party-api-clients

A place for keeping all our generated third party API clients.
https://docs.rs/octorust
MIT License
132 stars 55 forks source link

[github] fix potential overflow when computing rate limiting duration #58

Closed chantra closed 1 year ago

chantra commented 1 year ago

There is a change that SystemTime::now() is computed the second after the "reset" value, or simply clocks could also be slightly off.

When running in "release" mode, this can lead to an overflow, with the value returned being wrapped to the high u64 values.

https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=0c3610ae88babccc0c71ae6e18b07e60

This change ensures that we floor our result to 0 instead of wrapping to u64::MAX

chantra commented 1 year ago

I had this issue happening live. The application would handle the rate limit error and go to sleep until it is ready to resume. In this case, it would have gone to sleep for some 584942417355 years :D

augustuswm commented 1 year ago

Make sense to me. This should be applied to #57 as well.

chantra commented 1 year ago

Make sense to me. This should be applied to #57 as well.

Thanks. Yes, I will rebase.