sleep or
waitFor:
How it works
1
Wait, then act
Before a call, Quiesco waits until the app is idle. Then it taps, types or reads the screen.
2
The app reacts
The call starts work in the app: requests, timers, renders, animations.
3
Wait again
Quiesco waits until every tracker is idle, twice in a row one macrotask apart, so a timer
that starts a request in the same tick is not missed. Then the call returns.
sync.timeoutMs (10 s) fails with SYNC_TIMEOUT
(below).
Trackers
The agent in the app decides what “idle” means with these trackers. The app is idle when none is busy.
To turn one off:
network
network
- A
fetchcounts until the response arrives. Reading the body (json(),text(), …) right after keeps it busy until the body is in. expo/fetchis tracked too. Afetchbuilt on XHR (React Native) counts once.- A
WebSocket/EventSourcecounts only until it opens, fails or closes. Open connections never count, nor does the agent’s own connection. sync.ignoreUrlsleaves out long polling, SSE and analytics.
timer
timer
- Only timers up to
sync.timerThresholdMs(1.5 s) count: a 30 s session timeout does not block. setIntervalcounts only withsync.countIntervals: true.
react
react
- The tracker reads React’s own bookkeeping through the React DevTools hook: pending lanes, scheduled callbacks and tasks in React’s scheduler. Nothing in the app needs to change.
- The agent has to install that hook before React Native’s renderer loads.
withQuiesco()inmetro.config.jstakes care of it.
native (iOS)
native (iOS)
- Reported by
@quiesco/native: UIKit work that JavaScript cannot see, such as navigation and modal transitions. - The keyboard counts from UIKit’s
keyboardWill…notification to the matchingkeyboardDid…, at most the animation plus 0.5 s. iOS sometimes postskeyboardDidShowseconds late; the device log then has[Quiesco] keyboard: no Did notification ….
frame-stable
frame-stable
- Compares the element tree (type, testID, text, rounded position and size) frame by frame. Busy when
it changed in the last
sync.stableFrames(2) frames. - The fallback for animations that run on the UI thread (Reanimated, native-driver
Animated), which the other trackers cannot see. - It samples only while a call waits.
Why was a call slow, or too early?
Every call’s entry intimeline.html shows its wait for idle:
- Slow call: what the wait ended on, per tracker, e.g.
network: GET https://api.example.com/items (240ms). - Call returned too early: its last checks, e.g.
+272ms busy: native-module | +276ms idle | +277ms idle (confirmed), and the native module calls that started or settled meanwhile. The time is the device clock, to line up with the device log.
SYNC_TIMEOUT has this record too, and so does each step of a scrollTo.
When the app never becomes idle
The call fails withSYNC_TIMEOUT and lists what was busy:
Reading the report
Reading the report
- A tracker that was busy until shortly before the timeout but idle at that instant is listed too:
frame-stable (idle at the timeout, busy 12ms before it): …. A loop of “timer → render → a few quiet frames” is idle part of the time, and the timeout can land there. frame-stablenames the first element that changed, andrecent changeslists the latest changes. When one element keeps changing back and forth, the report names it.- Very few
frames sampledfor the time waited means the UI thread is starved (an overloaded emulator), not animating. idle-state.jsonshowsframe-stableidle after a timeout, because it samples only while a call waits. ItslastWaitkeeps what it reported when the wait ended.
A list that never settles
A list that never settles
A
FlatList / VirtualizedList without getItemLayout and with rows of slightly different heights
can keep adding and removing the item at the edge of its render window after a scroll: the report
shows an element added and removed each time. A longer timeoutMs does not help; getItemLayout or
fixed row heights usually stop it.Other fixes
Other fixes
- timer: lowering
sync.timerThresholdMsbelow the loop’s delay works too, but for every timer that short in the whole app. - frame-stable: when the moving element is not decoration, call the step with
{ sync: false }and assert what you need afterwards, or disable the animation in e2e builds. - network: a
MOCK_STALL-style switch in your mock server reproduces a stalled backend on purpose.
AGENT_TIMEOUT is different: the agent did not answer at all, usually because a long synchronous task
blocks the JS thread.Skipping sync for one call
Native module calls
By default, a pending native module call (AsyncStorage, a picker, …) does not keep the app busy. So an action can return too early:tap('login-submit') can return while setItem is pending, before the next screen has started. Two fixes:
- Wait for what the next step needs:
await app.expectVisible('item-row-1'). - Or track native module calls: wrap them in the e2e build, and restart Metro.
EXPO_PUBLIC_QUIESCO_NATIVE_MODULES=1 when starting Metro does the same. The native-module tracker is
then on. Its settings:
Calls that never count
Calls that never count
Some calls wait for the user and stay pending until the test answers them. They never count:
- permission requests: Expo modules and
PermissionsAndroid(*.request…Permission(s)(Async)) - date / time pickers:
RNCDatePicker.open,RNCTimePicker.open ExpoLocalAuthentication.authenticateAsync- share sheets:
ShareModule.share,ExpoSharing.shareAsync ExpoWebBrowser.openBrowserAsync/openAuthSessionAsync- image and document pickers
- alerts and action sheets:
AlertManager.alertWithArgs,DialogManagerAndroid.showAlert,ActionSheetManager.show…ActionSheetWithOptions - native-driver animations (
NativeAnimatedModule)
ignoreNativeCalls adds to this list; defaultIgnoreNativeCalls: false counts these calls too. Any
other call stops counting after nativeCallThresholdMs. The timeline names it
(native-module: Module.method() 1990ms), to add to ignoreNativeCalls.An event subscription (addListener(eventName, listener), add…Listener / remove…Listener(s))
counts only when it returns a promise, whatever defaultIgnoreNativeCalls says.What is not wrapped
What is not wrapped
- Modules taken during React Native’s startup, before the agent loads: React Native’s own modules.
Only modules from
TurboModuleRegistryand Expo’srequireNativeModuleafter that are wrapped. - Gesture Handler, Reanimated and Worklets: they call their modules from worklets on the UI thread, which needs the native functions.
Without the wrapping, or with the tracker off
Without the wrapping, or with the tracker off
- Without
nativeModules: truethe tracker counts nothing:trackers: { 'native-module': true }then logs a warning, andquiesco doctorwarns. - With the wrapping but the tracker off, the calls are still recorded: an action that returns while
one is pending lists it in its timeline entry, and a failed test’s
idle-state.jsonlists them (nativeCallsNotCounted).
Platform notes
- The same trackers run on all three platforms;
nativeexists only on iOS. - Web: the agent reconnects after a full page load, and Quiesco waits for it. With Expo Router’s static output, the app is ready after hydration.