Skip to content

Conversation

@gabmontes
Copy link
Member

@gabmontes gabmontes commented Aug 8, 2025

This PR fixes a minor bug when revalidating in promise-swr: If multiple calls to the wrapper were executed, multiple calls to the wrapped function fn could be made during the time it would take to revalidate (34be133).

Several other documentation and minor improvements were added.

PS: Thanks Copilot for helping me find this improvement opportunity!

Process checklist

  • Manual tests passed or not applicable.
  • Automated tests added or not applicable.
  • Documentation updated or not required.

Metrics

Actual effort: 1.5h

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the promise-swr library where multiple concurrent calls could trigger multiple revalidations during the stale-while-revalidate process. The fix adds a check to prevent revalidation when one is already in progress.

  • Adds a condition to prevent concurrent revalidations by checking !cached.revalidating
  • Removes the debug dependency and all debug logging statements
  • Improves TypeScript documentation with generic type parameters

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.

File Description
packages/promise-swr/src/index.js Fixes concurrent revalidation bug, removes debug logging, and adds TypeScript-style documentation
packages/promise-swr/package.json Removes debug dependency and bumps version to 1.0.2
packages/promise-swr/README.md Adds documentation clarifications for maxAge and resolver options

@gabmontes gabmontes force-pushed the fix-p-swr-revalidation branch from fee1385 to 3ccc412 Compare August 8, 2025 20:58
@gabmontes gabmontes force-pushed the fix-p-swr-revalidation branch from 3ccc412 to ca7dd1e Compare August 8, 2025 21:32
@gabmontes gabmontes marked this pull request as ready for review August 8, 2025 21:33
@gabmontes gabmontes enabled auto-merge August 8, 2025 21:33
@gabmontes gabmontes merged commit 813d649 into master Aug 11, 2025
4 checks passed
@gabmontes gabmontes deleted the fix-p-swr-revalidation branch August 11, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants