Skip to content

Adding handling for system tz not found exception #1625

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No 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? No Sign in to your account

Closed

Conversation

AutonomousCat
Copy link

Pull Request Type

  • Feature addition
  • [✓] Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement

Description

It handles a rare exception that was found while testing locally in a Windows 10 environment.

Changes

  • A try-except catch for the timestamp.astimezone() function in the return
  • Allows fallback handling to UTC, if the system tz isn't found at any time

@AstreaTSS
Copy link
Member

I'm somewhat against this idea as by all means, this is a Python and/or operating system bug. It's also a fallback that results in behavior that isn't necessarily consistent with how things usually acts (since UTC is far from being guaranteed as the user's timezone).

Not entirely against it, but still.

@AutonomousCat
Copy link
Author

@AstreaTSS The whole library should handle a fallback globally, possibly every connection refresh or initialization? But this fixes the only related bug I've noticed.

@AstreaTSS
Copy link
Member

@AstreaTSS The whole library should handle a fallback globally, possibly every connection refresh or initialization? But this fixes the only related bug I've noticed.

Gateway issues are usually machine-dependent, but they're usually down to things we wouldn't consider as bugs and usually happen in normal situations - IE connection being lost briefly.

Meanwhile, the fact this exists suggests the datetime library is getting an edge case on a - specific OS.

That being said, having done more research, what's likely happening here is that the datetime library is being passed a datetime that happens very near to the UNIX epoch. I found issues that suggest that using astimezone() on Windows like this makes things freak out.

Mind you, Discord timestamps shouldn't ever cause this issue, but from looking up the original error that you got, a user's presence can have a timestamp like this that I guess Discord just allows. This solution doesn't actually fix that specific issue - it just works around them.

@AutonomousCat
Copy link
Author

@AstreaTSS Well considering Windows users, the Exception is caught every time because Windows has the unix timestamp in milliseconds. Considering this function runs like 5 times a second (in a big server at least), maybe an overall runtime system check is needed?

@AstreaTSS
Copy link
Member

@AstreaTSS Well considering Windows users, the Exception is caught every time because Windows has the unix timestamp in milliseconds. Considering this function runs like 5 times a second (in a big server at least), maybe an overall runtime system check is needed?

That's not... quite correct. See my comments on Discord - this issue actually likely has to do with ActivityTimestamp's behavior.

@eightween
Copy link
Member

I'm 👎 on this PR, #1626 effectively addresses what I believe to be our issue at hand

@AstreaTSS
Copy link
Member

Superceded by #1626.

@AstreaTSS AstreaTSS closed this Mar 30, 2024
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants