feat: auto-mark app as ready on first inbound HTTP request#144
feat: auto-mark app as ready on first inbound HTTP request#144sohankshirsagar merged 1 commit intomainfrom
Conversation
Generated 5 tests - 5 passedTip New to Tusk Unit Tests? Learn more here. Test Summary
ResultsTusk's tests all pass and validate the core auto-ready feature comprehensively. The test suite confirms that View check history
Was Tusk helpful? Give feedback by reacting with 👍 or 👎 |


Summary
Removes the requirement for users to explicitly call
TuskDrift.markAppAsReady()in their service code. The SDK now automatically marks the app as ready when the first inbound HTTP server request is received. Users can still callmarkAppAsReady()explicitly if they need precise control over the timing.Changes
HttpInstrumentation._getServerEmitPatchFn()— when the firstrequestevent is emitted on an HTTP server and the app hasn't been marked ready yet,markAppAsReady()is called automatically.Design decisions
_getServerEmitPatchFnrather thanmodeUtils.ts: The auto-mark is placed at the HTTP serveremit('request')level — the earliest possible hook for inbound requests — rather than insidehandleRecordMode/handleReplayMode. This ensures the app is marked ready before sampling decisions, so it fires regardless of whether the specific request is sampled. It also fires before mode-specific logic, so it works for both record and replay.http.Serverall emitrequestevents, so this single hook point covers them all (including Next.js, which skips HTTP instrumentation deeper in_createServerSpanbut still passes through_getServerEmitPatchFn).isAppReady()guard ensures the check is a cheap boolean read on subsequent requests. If the user explicitly callsmarkAppAsReady()before any request arrives, the auto-mark path never fires.