Skip to content
New issue

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

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

Fixes log duplication issue #722

Merged
merged 0 commits into from
Apr 7, 2023
Merged

Fixes log duplication issue #722

merged 0 commits into from
Apr 7, 2023

Conversation

chance-an
Copy link
Contributor

A bug occurs when logs are already loading, and an accidental simultaneous scroll event triggers another log pull. The second pull will append the same logs twice.

According to the previous work, we can already sequentialize the pulls using a queue. So the fix is to avoid the second pull being issued if we discovered from the first pull that there would be no more logs.

This PR does such, and some extras:

  1. Add more loggings to understand the async queuing and execution details
  2. A helper function useRefFn to avoid the initial value of useRef being re-created multiple times across rendering. (see also here)
  3. Convert AsyncInvocationQueue from a function to a class to carry more responsibilities
  4. Updated unit test accordingly.

@chance-an chance-an added bug Something isn't working ui UI related work labels Apr 7, 2023
@chance-an chance-an requested review from neutralino1, tscurtu, augray and a team April 7, 2023 18:10
Copy link
Contributor

@tscurtu tscurtu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! :shipit:

sematic/ui/packages/main/src/hooks/logHooks.ts Outdated Show resolved Hide resolved
if (canceled !== true) {
// The server shouldn't return NaN, but just in case and be defensive,
// we don't want to add NaN to the accumulatedLines.
if (!isNaN(pulledLines!)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also log if this happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I interpret that we want to log the isNaN case instead of !isNan. If so, a change is made as change.

Copy link
Member

@augray augray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving because I tested and it appears to have resolved one case of duplicated logging that used to be fairly easy to reproduce.

@chance-an chance-an force-pushed the c/bug_log_dup branch 2 times, most recently from 708a2e3 to bdebd6e Compare April 7, 2023 19:21
@chance-an chance-an added this pull request to the merge queue Apr 7, 2023
Merged via the queue into main with commit 66e306a Apr 7, 2023
@chance-an chance-an deleted the c/bug_log_dup branch April 7, 2023 19:57
jrcribb pushed a commit to jrcribb/sematic that referenced this pull request Apr 9, 2024
A bug occurs when logs are already loading, and an accidental
simultaneous scroll event triggers another log pull. The second pull
will append the same logs twice.

According to the previous work, we can already sequentialize the pulls
using a queue. So the fix is to avoid the second pull being issued if we
discovered from the first pull that there would be no more logs.

This PR does such, and some extras:

1. Add more loggings to understand the async queuing and execution
details
2. A helper function `useRefFn` to avoid the initial value of `useRef`
being re-created multiple times across rendering. (see also
[here](facebook/react#14490))
3. Convert `AsyncInvocationQueue` from a function to a class to carry
more responsibilities
4. Updated unit test accordingly.

---------

Co-authored-by: tscurtu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ui UI related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants