Skip to main content
export declare function withNetworkSettledWait<T>(callback: (page: Page) => Promise<T>,
  options?: {
    page: Page;
    timeoutInMs?: number;
    maxInflightRequests?: number;
  }): Promise<T>;
Executes a callback function and waits for network requests to settle before returning. This function monitors network activity and waits for all pending requests to complete (or reach the specified maximum) before resolving. Useful for ensuring dynamic content has fully loaded after performing actions that trigger network requests.

Examples

import { withNetworkSettledWait } from "@intuned/browser";
export default async function handler(params, page, context){
// Navigate and ensure all resources are loaded
await withNetworkSettledWait(
  async (page) => {
    await page.goto('https://spa-app.com/dashboard');
    // Return when navigation is complete and network is idle
  },
  {
    page,
    timeoutInMs: 20000,
    maxInflightRequests: 0 // Wait for complete network silence
  }
);
}

Arguments

callback
Function
required
The callback function to execute. Receives the page object as parameter
options
Object
Configuration options for network monitoring

Returns: Promise<T>

Promise that resolves to the callback’s return value after network settles