October 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 PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Close a Puppeteer Connection Transport

Use transport.close() for a custom Puppeteer transport; use browser.disconnect() or browser.close() depending on whether the browser should keep running.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call transport.close() to close an implementation of Puppeteer’s ConnectionTransport interface. It is a synchronous method returning void. If you mean the browser session rather than the transport, use browser.disconnect() to detach Puppeteer while leaving the browser running, or browser.close() to shut down the browser and its pages.

Choose what you want to close

Goal Operation Effect
Close a custom transport transport.close() Synchronous void method on ConnectionTransport. Puppeteer API reference
Stop Puppeteer controlling a browser but keep the browser alive await browser.disconnect() Detaches Puppeteer; the browser process remains running. Puppeteer Browser API reference
Shut down the managed browser await browser.close() Closes the browser and its associated pages. Puppeteer Browser API reference
Close an isolated browser context await context.close() Closes that context and its pages. The default context cannot be closed. Puppeteer BrowserContext API reference
Close one page await page.close() Returns a promise; optionally accepts { runBeforeUnload?: boolean }. Puppeteer Page.close() API reference

Close a ConnectionTransport implementation

When your code owns an object implementing ConnectionTransport, call its close() method:

As an Amazon Associate I earn from qualifying purchases.

transport.close();

The interface also exposes optional onclose and onmessage callbacks and a send(message) method. The documented signature for close() is close(): void, so do not await it as though it returned a promise. ConnectionTransport API reference

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

What the interface does not specify

The interface signature identifies close() as the transport’s shutdown hook, but does not define whether a particular implementation must close a socket, notify listeners, be idempotent, or release additional resources. Follow and document the lifecycle contract of your transport implementation for those details.

Disconnect or close the browser session

Detach and leave the browser running

Use browser.disconnect() when Puppeteer should stop controlling the browser but another process or later Puppeteer connection should be able to use the still-running browser.

await browser.disconnect();

Shut down the browser

Use browser.close() when Puppeteer should close the browser it manages and the pages associated with it.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
await browser.close();

The browser API reference demonstrates disconnecting and reconnecting through the browser WebSocket endpoint before closing the browser. The browser-management guide is published under Puppeteer’s next documentation path, so check the stable API reference and your installed version when behavior is version-sensitive. Browser management guide

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

Close a context or a single page instead

If the browser should stay open but only a portion of its work should end, close the narrower target:

  • One page: await page.close(). It returns a promise and can take { runBeforeUnload: true } when the page’s before-unload behavior should run. Page.close() API reference
  • An isolated context: await context.close() closes the context and all its pages. Puppeteer’s default context cannot be closed. BrowserContext API reference

Common mistakes and fixes

  • Awaiting transport.close(): it is documented as returning void, not a promise. Call it directly.
  • Using browser.close() when the browser must remain available: use browser.disconnect() to detach Puppeteer without shutting down the browser process.
  • Using browser.disconnect() when the browser must stop: disconnecting leaves the browser process running; use browser.close() to shut it down.
  • Trying to close the default context: the default context cannot be closed. Close an isolated context or close individual pages instead.
  • Assuming the interface defines socket or event cleanup: it does not specify those implementation details. Check the transport’s own lifecycle documentation and handle its resources accordingly.

Or skip the browser setup

If your goal is simply to capture a website rather than manage a Puppeteer browser session, ScreenshotNeo returns a screenshot or PDF from one GET request. Its API removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.

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

See the ScreenshotNeo API documentation, then sign up for 1,000 free screenshots a month, with no card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Version note

Puppeteer’s stable API references surfaced in versions 25.3.0 through 25.12.0. Confirm the method signatures and version-specific behavior against the documentation for the version installed in your project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

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.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.