How to fix Fetch.enable wasn't found error for workers in Puppeteer

Puppeteer

Fetch.enable wasn't found is raised when trying to enable the Fetch domain for a worker. The fix is to ignore this error for workers since the feature is not applicable there; the code path in WebWorker.ts already catches and handles this error. You can guard around the call and ignore errors that mention Fetch.enable wasn't found. Example:

try {
  await session.send('Fetch.enable', { /* options */ });
} catch (err) {
  if (err && typeof err.message === 'string' && err.message.includes("Fetch.enable wasn't found")) {
    // ignore for workers
  } else {
    throw err;
  }
}

This behavior is implemented in the Puppeteer Core WebWorker handling, which catches the error appropriately and prevents it from failing the flow.