Skip to content

Commit

Permalink
fix(crash): handle sleep/wake appropriately (#5787)
Browse files Browse the repository at this point in the history
## Problem:

When a user does a sleep then wake of their computer, the heartbeat is
not up to date since it cannot be sent when the user's computer is
asleep.

Due to this there is a race condition on wake between the next fresh
heartbeat being sent versus when we check the heartbeats to determine if
they are stale (crash). If the crash checker runs before a new heartbeat
can be sent, it will be seen as a crash.

## Solution:

Use a TimeLag class that helps to determine when there is a time
discrepancy. It works by updating a state every second, and if we
determine that the next update to that state took longer than a second,
we determine that there was a lag. Then we simply skip the next crash
check, allowing a fresh heartbeat to be sent.

---

<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->

License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

---------

Signed-off-by: nkomonen-amazon <[email protected]>
  • Loading branch information
nkomonen-amazon authored Oct 17, 2024
1 parent af41d26 commit 449de46
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 126 deletions.
6 changes: 1 addition & 5 deletions packages/core/src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ export const amazonQVscodeMarketplace =
*
* Moved here to resolve circular dependency issues.
*/
export const crashMonitoringDirNames = {
root: 'crashMonitoring',
running: 'running',
shutdown: 'shutdown',
} as const
export const crashMonitoringDirName = 'crashMonitoring'

export const amazonQTabSuffix = '(Generated by Amazon Q)'
Loading

0 comments on commit 449de46

Please sign in to comment.