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

feat(client): add debounce on page reload #13545

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

btea
Copy link
Collaborator

@btea btea commented Jun 17, 2023

Description

close #13512

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Jun 17, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev
Copy link
Member

Thanks for the PR @btea!
@GeorgeZhangZHY would you help us test this PR? I think 50ms is a sensible delay here.

@patak-dev patak-dev added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jun 19, 2023
}, time)
}
}
const pageReload = debounceReload(50)

Choose a reason for hiding this comment

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

may be just use lodash.debounce is better?

Copy link
Member

Choose a reason for hiding this comment

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

It is better to avoid dependencies in client.ts, we serve this file during dev to the browser.

@GeorgeZhangZHY
Copy link

How?

Thanks for the PR @btea! @GeorgeZhangZHY would you help us test this PR? I think 50ms is a sensible delay here.

Don't know how to test it as there's no beta Vite package. I guess it‘s sufficient for my Mac. Maybe a little bit larger delay such as 80~100ms can cover more less performant machines.

@patak-dev
Copy link
Member

I'm a bit hesitant to add a longer timeout without proper testing for its need. About testing PRs, you can clone and build Vite and use an override in your app to the local Vite (if you use pnpm, it would be https://pnpm.io/package_json#pnpmoverrides for example). But I think this debounce makes sense, we could merge it, and you can test using the beta release soon.

@patak-dev patak-dev requested a review from bluwy June 19, 2023 13:27
@bluwy bluwy merged commit d080b51 into vitejs:main Jun 19, 2023
@btea btea deleted the feat/page-reload-debounce branch June 19, 2023 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should debounce page reload requests
4 participants