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

subscriptions.rs: Negative publish_request_timeout value causes expire_stale_publish_requests function to panic #315

Open
evanjs opened this issue Mar 8, 2024 · 0 comments

Comments

@evanjs
Copy link

evanjs commented Mar 8, 2024

After the time crate removal in #260, if pulish_request_timeout is negative, then subscriptions#expire_stale_publish_requests will panic
This is because to_std outputs a Duration, which can only be unsigned (positive).

Since the input value is negative, this will fail immediately.

Here is a playground example of a request timestamp and "now" timestamp that will fail


While this issue was fairly easy to work around, I have no idea if there are any potential implications from this approach.
Nor do I know why I might have been seeing negative durations in the first place, beyond non-absolute date synchronization between server/client

Anyway, as seen here

  • Duration::from_millis is replaced with chrono::Duration::milliseconds
  • signed_duration_since is changed from Duration to chrono::Duration
  • .to_std().unwrap() is removed.

Barring the potential impacts of not expiring negative signed_duration_since values (and the reason they are negative in the first place), this seems to at least avoid panics when such values are encountered.

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