What is a transport?
A transport is a reusable network layer handle that owns:- Transport-level settings like
proxy,browser,os, andinsecure - Reusable network context used by requests and sessions
When should I use Transport vs Sessions?
Use the simplest tool that matches your needs:Creating and reusing a transport
A common pattern is one transport per proxy, reused across many requests:Using Transport with sessions
Sessions are the right default for cookie-based flows. If you want multiple sessions (separate cookies) to share a single transport context (same proxy/emulation), pass the same transport per request:Ownership rules (important)
When you pass atransport, it owns browser, os, proxy, and insecure.
- Do not also set
browser,os,proxy, orinsecureon the request. - Prefer creating a separate transport if you need different settings.
Lifecycle
Always close transports you create:- Close when you no longer need the transport:
await transport.close() - After closing, the transport cannot be used again
Related
- API details:
createTransport() - Cookie flows: Sessions