Skip to content

clear timer when delete cached data from cache#2909

Open
jungleyu wants to merge 1 commit intoalibaba:masterfrom
jungleyu:fix/clearTimer
Open

clear timer when delete cached data from cache#2909
jungleyu wants to merge 1 commit intoalibaba:masterfrom
jungleyu:fix/clearTimer

Conversation

@jungleyu
Copy link
Copy Markdown

@jungleyu jungleyu commented Mar 4, 2026

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

The timer was not removed when delete cached data from the map, which will cause unexpected data deletion.

📝 Changelog

Language Changelog
🇺🇸 English Clear the timer before invoke cache.delete(cacheKey)
🇨🇳 Chinese 在调用cache.delete(cacheKey)之前清除可能设置的timer

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 4, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

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

Fixes a cache eviction bug in useRequest’s in-memory cache where timers could outlive deleted cache entries and later delete newly-created entries for the same key.

Changes:

  • Introduce a clearTimer helper to centralize timeout cleanup.
  • Ensure clearCache(key) and clearCache() clear any outstanding timers before deleting cache entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants