-
Notifications
You must be signed in to change notification settings - Fork 3
Description
On MacOS Ventura 13.5.2, running System.system_time(:second) appears to drift if the machine has slept. This means that during development you may find that the nbf claim fails intermittently, requiring you to restart your application.
You should be able to reproduce this by running an application, sleeping the machine, and then trying to log back in to the application. If you want to verify the behavior of System.system_time then you can start an IEx session, then sleep your machine for some period of time. When you return to the session, you can get the system time, and in another session started after you wake up your machine check it as well. It should be close to the amount of time that your machine was asleep for.
For example:
On the left is the session that got slept, on the right is a session started after waking up the machine.
I'd love to dig down to the actual system calls and figure out why this is happening. Maybe it's the Erlang VM caching in some expected way? I'm not actually sure if it's system specific or if this is expected behavior. The Erlang call underlying System.system_time is :erlang.system_time which is documented to give you the Erlang view of the OS time. It's stated that this may not match the OS view of the time.
At any rate, the issue of failing nbf claims would be fixed by swapping System.system_time(:second) with :os.system_time(:second) in lib/verify/claims.ex. That is, unless I've misunderstood the nature of the verification and this is expected behavior.