-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Environment
@sentry-internal/node-native-stacktrace@npm:0.2.1
On linux and macos.
Steps to Reproduce
- Enable eventLoopBlockIntegration.
- Run node instance with eventLoopBlockIntegration enabled on Google Cloud Run with the instance in request billing mode. This will also work from a laptop.
- Observe EventLoopBlocked notifications every time the system suspends.
Expected Result
System suspension should not be detected as a blocked event loop.
Actual Result
System suspension is detected and reported as a blocked event loop
Additional information
The event loop block integration currently uses std::chrono::system_clock::now()
for detecting when the event loop is blocked (code). On linux, Gcc's libstdc++ uses clock_gettime()
with CLOCK_REALTIME
to or gettimeofday()
get the time depending on the settings. The documentation specifically states that CLOCK_MONOTONIC
can be used to ignore time when the system is suspended. The std::chrono::steady_clock::now()
implementation on linux uses this call, but on macos llvm's libcxx specifically chooses CLOCK_MONOTONIC_RAW
on that platform so that the clock tracks suspends (docs). On macos you want CLOCK_UPTIME_RAW
or CLOCK_UPTIME_RAW_APPROX
. On windows you want QueryUnbiasedInterruptTimePercise()
or QueryUnbiasedInterruptTime()
.
So basically, you need to implement a custom time function that does the right thing on each platform as there doesn't appear to be one in the standard library.