Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

How to Close a Web Worker in Puppeteer

Puppeteer exposes worker.close() for a WebWorker. Learn how to find page workers, observe their lifecycle, and choose a broader cleanup method when needed.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call await worker.close() on a Puppeteer WebWorker instance. To find dedicated workers attached to a page, use page.workers(); it does not include ServiceWorkers. Puppeteer also exposes page events for observing worker creation and destruction.

Close a Puppeteer WebWorker

When you already have a worker object, close it directly:

As an Amazon Associate I earn from qualifying purchases.

await worker.close();

The Puppeteer API reference lists WebWorker.close(), but does not specify its protocol-level implementation. Treat it as the documented worker API rather than assuming details about how the browser terminates the underlying worker. Puppeteer WebWorker API

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Find and observe page workers

page.workers() returns the dedicated WebWorkers associated with a page. It explicitly excludes ServiceWorkers. Use the worker URL to identify each listed worker:

for (const worker of page.workers()) {
  console.log('Worker URL:', worker.url());
  await worker.close();
}

To observe worker lifecycle changes on a page, listen for workercreated and workerdestroyed:

page.on('workercreated', worker => {
  console.log('Worker created:', worker.url());
});

page.on('workerdestroyed', worker => {
  console.log('Worker destroyed:', worker.url());
});

These event names and methods are documented by Puppeteer. The examples show how to combine them; they are not claims of a tested run. Puppeteer Page API

Choose the cleanup scope you need

Closing a worker is narrower than closing its page or browser. Choose the method whose documented scope matches the cleanup you intend:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Method Documented scope
await worker.close() Closes the Puppeteer WebWorker instance; the API entry does not detail protocol-level behavior. WebWorker API
await page.close() Closes the page. Page.close()
await browserContext.close() Closes the browser context and its associated pages. The default browser context cannot be closed. BrowserContext.close()
await browser.close() Closes the browser and all associated pages. Browser.close()
await browser.disconnect() Detaches Puppeteer while leaving the browser process running; this is not browser shutdown. Browser.disconnect()

These are different cleanup scopes. The documented scopes do not establish that closing a page, context, or browser has exactly the same lifecycle semantics as calling WebWorker.close().

Common mistakes and checks

  • Looking for a ServiceWorker in page.workers(): that method excludes ServiceWorkers. It lists dedicated WebWorkers associated with the page.
  • Closing the browser when only a worker should be addressed: browser.close() closes the browser and all associated pages, a broader action than calling worker.close().
  • Using browser.disconnect() to stop the browser: disconnect detaches Puppeteer but leaves the browser process running. Use browser.close() when the goal is browser shutdown.
  • Assuming undocumented termination mechanics: Puppeteer’s API lists the worker’s close() method but does not describe its protocol implementation. Rely on the documented method and scope, not an inferred mechanism.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is to capture a page rather than manage Puppeteer workers, ScreenshotNeo provides a screenshot API and MCP server. One GET request returns a screenshot or PDF; the request below saves a WebP screenshot. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Before capture, ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response includes X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.