Skip to content

fix: add actionable warning for background requests during replay#139

Merged
sohil-kshirsagar merged 2 commits intomainfrom
fix/replay-background-request-warning
Mar 16, 2026
Merged

fix: add actionable warning for background requests during replay#139
sohil-kshirsagar merged 2 commits intomainfrom
fix/replay-background-request-warning

Conversation

@sohil-kshirsagar
Copy link
Contributor

@sohil-kshirsagar sohil-kshirsagar commented Mar 16, 2026

Upgrades the no-op background request log from debug to warn with actionable guidance. When background jobs, scheduled tasks, or middleware (e.g., rate limiters, AMQP consumers) fire outside a test trace during replay, the log now tells users to disable these services when TUSK_DRIFT_MODE=REPLAY.

TODO: Have the setup agent detect background services and automatically configure the app to skip them during replay.

@sohil-kshirsagar sohil-kshirsagar force-pushed the fix/replay-background-request-warning branch 2 times, most recently from bc07ea1 to 2e7b2fd Compare March 16, 2026 15:59
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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">
P2: Calling `doc("")` here can throw instead of generating an auto-ID, so replayed background `collection.add()` no-ops may fail immediately.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@sohil-kshirsagar sohil-kshirsagar force-pushed the fix/replay-background-request-warning branch from 2e7b2fd to 99daddd Compare March 16, 2026 16:03
@tusk-dev
Copy link

tusk-dev bot commented Mar 16, 2026

Generated 11 tests - 11 passed

Commit tests View tests

Tip

New to Tusk Unit Tests? Learn more here.

Test Summary

  • handleRecordMode - 7 ✓
  • handleReplayMode - 4 ✓

Results

Tusk's tests all pass. The test suite validates the core routing logic in handleReplayMode and handleRecordMode, with particular focus on the new warning behavior for background requests during replay. The critical path here is handleReplayMode detecting when background jobs or middleware fire outside a test trace (app ready, no span context, non-server request) and logging an actionable warning telling users to disable these services when TUSK_DRIFT_MODE=REPLAY. The tests confirm this warning fires correctly while ensuring legitimate server requests and traced requests still route to the proper handlers. Error handling in handleRecordMode is also validated—fallbacks to originalFunctionCall work when getInstance or getCurrentSpanInfo fail, preventing silent failures. The routing logic correctly distinguishes between pre-app-start, in-trace, and background request scenarios across both modes.

View check history

Commit Status Output Created (UTC)
f246863 Skipped due to new commit on branch Output Mar 16, 2026 3:53PM
bc07ea1 Skipped due to new commit on branch Output Mar 16, 2026 3:57PM
2e7b2fd Skipped due to new commit on branch Output Mar 16, 2026 3:59PM
99daddd Skipped due to new commit on branch Output Mar 16, 2026 4:03PM
1ed0234 Generated 11 tests - 11 passed Tests Mar 16, 2026 10:13PM

Was Tusk helpful? Give feedback by reacting with 👍 or 👎

@sohil-kshirsagar sohil-kshirsagar merged commit 5388cae into main Mar 16, 2026
19 checks passed
@sohil-kshirsagar sohil-kshirsagar deleted the fix/replay-background-request-warning branch March 16, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants