Fix hot keys returning empty on first MONITOR cycle - #434
Merged
Conversation
nassery318
reviewed
Jul 30, 2026
| // Reads monitor data and returns when to fetch results (`checkAt`). | ||
| if (initialParsedResponse.checkAt) { | ||
| const delay = initialParsedResponse.checkAt - Date.now() | ||
| // Add 1s buffer: checkAt marks when collection ends, but data is written |
Contributor
There was a problem hiding this comment.
wondering, what if the disk takes longer than 1s (it is under load, or it is a slow disk)? the refetch will still return empty.
Collaborator
Author
There was a problem hiding this comment.
Good question. Initially, I thought 1s delay is a good tradeoff. Now that I think about it maybe we should do a limit of retries until we hit that limit or until we get data back.
Collaborator
Author
There was a problem hiding this comment.
Made the changes
Signed-off-by: ravjotb <ravjot.brar@improving.com>
ravjotbrar
force-pushed
the
fix/hotkeys-rendering
branch
from
July 30, 2026 16:40
264495e to
d7011b4
Compare
Signed-off-by: ravjotb <ravjot.brar@improving.com>
ArgusLi
approved these changes
Jul 30, 2026
ArgusLi
left a comment
Contributor
There was a problem hiding this comment.
The "best" solution would somehow be to send a signal after disk write, then we wait for that before getting the result, but that would be completely overkill. This works.
ravjotbrar
added a commit
that referenced
this pull request
Jul 30, 2026
* Fix hot keys returning empty on first MONITOR cycle Signed-off-by: ravjotb <ravjot.brar@improving.com> * Retry hot keys fetch with 1s interval instead of single buffer Signed-off-by: ravjotb <ravjot.brar@improving.com> --------- Signed-off-by: ravjotb <ravjot.brar@improving.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prior to this change, the server waits until checkAt (collection end time) then immediately re-fetches /hot-keys. But monitor data is collected in memory for the full duration, then written to disk after collectLogs returns. The re-fetch arrives before the write completes, returning empty results.
This PR adds a 1-second buffer to the hot keys re-fetch delay after checkAt to account for the asynchronous disk write that happens after monitor collection ends. The 1-second buffer accounts for: promise resolution + event listener cleanup + JSON serialization of rows + fs.appendFile.
Before the fix
Screen.Recording.2026-07-29.at.5.25.01.PM.mov
After the fix
Screen.Recording.2026-07-29.at.5.15.40.PM.mov