Repository navigation
fix(incremental): reject revalidateTag when the tag state could not be written - #23
Merged
Merged
Conversation
…e written With no Redis connection (failed initialization, or the reconnect cooldown) getOrConnect() returns null. revalidateTag returned from its callback, fell through to the success path and emitted a tag.invalidate metric with backend "redis", so the caller could not tell an unwritten invalidation from a confirmed one while other instances kept serving the old entry. Throw in that case. The existing catch already decides what propagates: an invalidation with a deadline rejects, exactly as it does when the write fails or times out. The local stamp is applied before the remote write, so the calling process is invalidated either way. Memory-only modes are untouched. Closes #13
Merged
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13.
Problem
With no Redis connection (failed initialization, or the reconnect cooldown)
getOrConnect()returnsnull. The singular handler'srevalidateTagreturned from its callback, fell through to the success path and emittedtag.invalidate.*withbackend: "redis". Nothing had been written, other instances kept serving the old entry, and the caller could not tell.A failed or timed-out write already rejected. Only the no-connection case was silent, which also contradicted
docs/api.md.Change
Throw when there is no client. The existing
catchdecides what propagates, so the no-connection case now behaves exactly like a failed write: an invalidation with a deadline (no durations, or durations with anexpire) rejects, and no success metric is emitted. The local stamp is applied before the remote write, so the calling process is invalidated either way. Memory-only modes (fallback: "always", build phase,instance-local:tags) are untouched.Verification
Unit: 196 passed. The 6 new cases fail on current main.
End to end on Next.js 16.4.6, real Redis stopped mid-run:
updateTag()revalidateTag(tag, 'max')revalidateTag(tag, 'max')Next awaits the invalidation only for
updateTag()in a Server Action. ForrevalidateTag(tag, 'max')it runs the handler after the response, so the rejection is logged by Next rather than returned to the client. Pages keep being served from the memory fallback during the outage, and invalidation works again once Redis is back.Not in this PR
The issue also proposes waiting for auto-connecting ioredis clients and new cluster options. Those are separate changes.