-
Notifications
You must be signed in to change notification settings - Fork 87
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
fix: make revalidateTags
no-op when list of tags is empty
#2727
Conversation
📊 Package size report 0%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tests/integration/simple-app.test.ts
Outdated
@@ -22,6 +24,8 @@ import { | |||
startMockBlobStore, | |||
} from '../utils/helpers.js' | |||
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs' | |||
import { purgeCache } from '@netlify/functions' | |||
import { afterEach } from 'node:test' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 shouldn't this be from vitest
like all the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh, yes, this was result of import being automatically added and me not noticing it was wrong one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// allow for cache entry to get stale | ||
await new Promise((res) => setTimeout(res, 2000)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is mocking and advancing the clock here problematic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use above in plenty of other places that check behaviors related to stale cache items so I just the same method here
I'm not sure if attempting to mock time would work - conceptually it should of course, but not sure it's worth doing that as most time is spent on setting up fixtures rather than running the test itself anyway (at least in this case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go ahead and keep this as is in effort to get this fix out and would say moving to mocking time instead of using ~sleep
is something to consider (across all unit and integration tests and not just this one) - just let's not use this PR for this
Description
Makes the
revalidateTags
call a no-op when the array of tags is empty.Tests
Added integration test with scenario resulting in Next.js calling
CacheHandler.revalidateTag
with empty array of tags and ensuring purge API endpoint is not being usedRelevant links (GitHub issues, etc.) or a picture of cute animal
https://linear.app/netlify/issue/FRB-1536/dont-call-purgecache-when-tags-is-empty-array