Skip to content

Commit bc07ea1

Browse files
fix: add actionable warning for background requests during replay
1 parent 5df98d6 commit bc07ea1

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/instrumentation/core/utils/modeUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export function handleReplayMode<T>({
7373

7474
// Background request: App is ready + not within a trace (no parent span) + not a server request
7575
if (isAppReady && !currentSpanInfo && !isServerRequest) {
76-
logger.debug(`[ModeUtils] Handling no-op request`);
76+
logger.warn(
77+
`[TuskDrift] Background request detected during replay (no active trace context). This typically means a background job, scheduled task, or middleware (e.g., rate limiters, message consumers) is running outside of a test trace. To avoid errors, disable these services when TUSK_DRIFT_MODE=REPLAY.`,
78+
);
7779
// This is a background request (app is ready and no parent span), call the backgroundRequestHandler
7880
return noOpRequestHandler();
7981
}

src/instrumentation/libraries/firestore/Instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,11 @@ export class FirestoreInstrumentation extends TdInstrumentationBase {
699699
if (self.mode === TuskDriftMode.REPLAY) {
700700
return handleReplayMode({
701701
noOpRequestHandler: () => {
702-
if (!self.originalCollectionDocFn) {
702+
if (!this.originalCollectionDocFn) {
703703
logger.error(`[FirestoreInstrumentation] Original doc function not available`);
704704
return Promise.reject(new Error("Original doc function not available"));
705705
}
706-
return self.originalCollectionDocFn.call(this);
706+
return this.originalCollectionDocFn.call(this, "");
707707
},
708708
isServerRequest: false,
709709
replayModeHandler: () => {

0 commit comments

Comments
 (0)