Skip to content

Commit 6402be6

Browse files
mcollinaclaude
andcommitted
fix: use process.nextTick instead of setImmediate for background revalidation
setImmediate doesn't work properly with fake timers in tests, causing background revalidation to not trigger. process.nextTick works correctly with both real time and fake timers. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matteo Collina <hello@matteocollina.com>
1 parent 1650483 commit 6402be6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/interceptor/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function handleResult (
254254
sendCachedValue(handler, opts, result, age, null, true)
255255

256256
// Start background revalidation (fire-and-forget)
257-
setImmediate(() => {
257+
process.nextTick(() => {
258258
let headers = {
259259
...opts.headers,
260260
'if-modified-since': new Date(result.cachedAt).toUTCString()

0 commit comments

Comments
 (0)