fix: resolve replay mode errors in Redis and Firestore no-op request handlers#138
Merged
sohankshirsagar merged 2 commits intomainfrom Mar 13, 2026
Merged
Conversation
sohil-kshirsagar
approved these changes
Mar 13, 2026
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/instrumentation/libraries/firestore/Instrumentation.ts">
<violation number="1" location="src/instrumentation/libraries/firestore/Instrumentation.ts:706">
P1: Calling Firestore `doc("")` here can still throw in replay mode. Use `doc()` with no argument so the no-op path returns an auto-ID `DocumentReference` instead of an invalid empty document path.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
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.

Summary
Fixes two bugs in replay mode that cause crashes when background requests hit the
noOpRequestHandlerpath inhandleReplayMode. A customer reportedTypeError: Expected result to be array of valuesfromrate-limit-redisandError: Original doc function not availablefrom Firestore during replay.Changes
sendCommandandcommandsExecutorno-op handlers.Previously both returned
undefined, which breaks callers that validate the response type. For example,rate-limit-redisusesEVALSHAand strictly expects an array result — receivingundefinedthrowsTypeError: Expected result to be array of values. Now returns[]forEVAL/EVALSHAcommands andnull(standard Redis nil) for everything else.this/selfscoping bug incollection.addno-op handler.The
noOpRequestHandlerarrow function capturedthisfrom the enclosing regular function, which binds to theCollectionReferenceinstance — not theFirestoreInstrumentationinstance whereoriginalCollectionDocFnis stored. Changedthis.originalCollectionDocFn→self.originalCollectionDocFnso the property lookup hits the instrumentation class. The.call(this, "")argument correctly remainsthis(theCollectionReferencecontext).\Context
The Redis error specifically surfaces when
rate-limit-redisexpress middleware fires during replay. The rate limiter's Redis calls land on the no-op path because they execute before/outside the SDK's HTTP span context, sohandleReplayModeclassifies them as background requests. The no-op handler just needs to return a value that won't crash the caller — the rate limiter effectively becomes a pass-through in replay mode.The Firestore error surfaces from AMQP consumer jobs (
ch.consume) that write to Firestore outside of any traced HTTP request — these are genuine background requests where the no-op path is the correct behavior, but thethis/selfbug prevented it from working.