Summary
We’re trying to use Lightpanda with Playwright (CDP) to generate PDFs in our API, but the connection fails when running on Bun.
This is currently blocking us from using Lightpanda in production.
We only use Playwright in this project (no Puppeteer).
Setup
-
Lightpanda: v1.2.0
-
Playwright Core: v1.58.2
-
Runtime: Bun 1.3.9
-
Lightpanda started with:
lightpanda serve --port 9222
What we’re doing
const browser = await chromium.connectOverCDP({
endpointURL: "ws://127.0.0.1:9222/",
});
Error
This is the exact error we’re getting:
Failed to connect to Lightpanda CDP at ws://127.0.0.1:9222/: overCDP: WebSocket error: ws://127.0.0.1:9222/ 101 Switching Protocols
Call log:
- <ws connecting> ws://127.0.0.1:9222/
- <ws unexpected response> ws://127.0.0.1:9222/ 101 Switching Protocols
- <ws error> ws://127.0.0.1:9222/ error WebSocket was closed before the connection was established
- <ws connect error> ws://127.0.0.1:9222/ WebSocket was closed before the connection was established
- <ws disconnected> ws://127.0.0.1:9222/ code=1006 reason=
From logs:
connection successfully upgraded
connection closed: error.ConnectionResetByPeer
Behavior
- Connection starts
- Server responds with
101 Switching Protocols
- Then connection immediately closes (code 1006)
- Playwright never establishes a session
Fails on Bun
If we build with:
- WebSocket fails immediately
- Same code, same Lightpanda instance
Context
- This is for a large project (exam platform)
- We generate PDFs at scale
- Frontend runs on Node
- API runs on Bun
- We want to use Lightpanda for performance reasons
Switching everything to Node just to make this work isn’t ideal for us.
Question
Is Playwright + Lightpanda expected to work on Bun?
Or is this a known limitation with CDP / WebSocket handling?
Related
What we need
Just trying to understand:
- Is this expected to work?
- If not, is there a recommended setup for Playwright users?
- Any workaround we should try?
Happy to test anything or provide more logs if needed.
Summary
We’re trying to use Lightpanda with Playwright (CDP) to generate PDFs in our API, but the connection fails when running on Bun.
This is currently blocking us from using Lightpanda in production.
We only use Playwright in this project (no Puppeteer).
Setup
Lightpanda: v1.2.0
Playwright Core: v1.58.2
Runtime: Bun 1.3.9
Lightpanda started with:
What we’re doing
Error
This is the exact error we’re getting:
From logs:
Behavior
101 Switching ProtocolsFails on Bun
If we build with:
Context
Switching everything to Node just to make this work isn’t ideal for us.
Question
Is Playwright + Lightpanda expected to work on Bun?
Or is this a known limitation with CDP / WebSocket handling?
Related
What we need
Just trying to understand:
Happy to test anything or provide more logs if needed.