-
Notifications
You must be signed in to change notification settings - Fork 0
Technical Architecture
Understanding how DevMirror works under the hood.
DevMirror is built on Puppeteer-core and the Chrome DevTools Protocol (CDP) to capture console output.
- Lightweight: No bundled Chrome/Chromium download
- Flexible: Works with any Chrome/Chromium installation
- Protocol Access: Direct CDP access for console capture
- Cross-Platform: Works on Windows, macOS, Linux
- Reliable: Battle-tested by millions of developers
VS Code Extension
↓
DevMirror CLI
↓
Puppeteer-core
↓
Chrome DevTools Protocol
↓
Target Application (Browser/CEF/Node)
DevMirror uses Puppeteer-core to:
- Detect running Chrome/Chromium instances
- Connect via WebSocket to debug port
- Establish CDP session
// Simplified connection logic
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://localhost:9222/devtools/browser/...',
defaultViewport: null
});Using Chrome DevTools Protocol events:
-
Runtime.consoleAPICalled- Console method calls -
Runtime.exceptionThrown- Uncaught exceptions -
Log.entryAdded- Browser logs -
Page.javascriptDialogOpening- Alerts/confirms
DevMirror processes each console event:
- Extracts message type (log, warn, error, info)
- Serializes complex objects
- Preserves stack traces
- Formats timestamps
- Writes to log file
- Protocol for debugging/profiling Chrome
- WebSocket-based communication
- JSON-RPC message format
- Used by Chrome DevTools, Puppeteer, Playwright
Runtime Domain:
- Execute JavaScript
- Monitor console API
- Handle exceptions
Page Domain:
- Page lifecycle events
- Navigation monitoring
- Dialog handling
Network Domain:
- Request/response tracking
- WebSocket monitoring
- Cache control
Log Domain:
- Browser logs
- Violation reports
- Deprecation warnings
// Connect to standard Chrome
puppeteer.connect({
browserURL: 'http://localhost:9222',
defaultViewport: null
});- Default port: 9222
- Works with: Chrome, Chromium, Edge, Brave
- Use for: Web applications
// Connect to CEF application using direct CDP connection
// No browser launch required - connects to existing CEF debug port- Default port: Configurable via config.cefPort
- Works with: Adobe CEP, Electron with CEF
- Use for: Desktop applications
// Node.js debugging is not currently supported
// Use CDP mode for browser-based applications only- Default port: N/A
- Works with: Not supported
- Use for: Not supported
- Status: Not implemented
| Feature | Puppeteer | Puppeteer-core |
|---|---|---|
| Chrome included | Yes (~170MB) | No |
| Package size | ~170MB | ~3MB |
| Auto-download | Yes | No |
| Chrome detection | Automatic | Manual |
| Use case | Testing | Connecting to existing Chrome |
DevMirror uses puppeteer-core because:
- Smaller package size
- Uses your existing Chrome
- Works with any Chromium-based browser
- No unnecessary Chrome downloads
DevMirror uses a simple Chrome detection strategy:
- Default path:
C:\Program Files\Google\Chrome\Application\chrome.exe - Override via:
chromePathin config or VS Code settings
- Default path:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome - Override via:
chromePathin config or VS Code settings
- Default command:
google-chrome - Override via:
chromePathin config or VS Code settings
Note: For custom Chrome installations, set the chromePath in your DevMirror configuration or VS Code settings.
- Puppeteer-core: ~30MB
- CDP connection: ~10MB per page
- Log buffering: Configurable
- Minimal when idle: <1%
- During capture: 2-5%
- Serialization overhead: Negligible
- WebSocket connection: Minimal
- Message size: ~1KB per log
- Compression: Supported
- Connections restricted to localhost
- No external network access
- No data sent outside
- Read-only console access
- No page modification
- No script injection (default)
- Separate CDP session
- No interference with DevTools
- Independent of page state
Complex objects are serialized:
console.log({ deep: { nested: { object: true }}});
// Captured as formatted JSONError stack traces maintained:
Error: Something went wrong
at function1 (app.js:10:5)
at function2 (app.js:20:10)Handles async console calls:
setTimeout(() => console.log('Delayed'), 1000);
// Still capturedCaptures from all pages/frames:
- Main page
- iframes
- Pop-ups
- Web Workers
# Check if CDP is available
curl http://localhost:9222/json
# Response shows debuggable targetsDevMirror uses console output for logging. Check the VS Code Output panel (DevMirror channel) or terminal output for debugging information.
# Using Chrome DevTools
chrome://inspect/#devicesTarget closed
- Page was closed
- Browser crashed
- Connection lost
Protocol error
- Incompatible Chrome version
- Invalid CDP command
- Timeout exceeded
WebSocket error
- Port not available
- Firewall blocking
- Wrong endpoint
| Browser | Version | Support |
|---|---|---|
| Chrome | 89+ | Full |
| Chromium | 89+ | Full |
| Edge | 89+ | Full |
| Brave | 1.20+ | Full |
| Opera | 75+ | Partial |
| Firefox | - | No (uses different protocol) |
| Safari | - | No (uses different protocol) |
- WebDriver BiDi support (cross-browser)
- Firefox DevTools Protocol support
- Safari Web Inspector support
- Native Node.js integration
- Performance profiling capture
- Network request logging
- Chrome DevTools Protocol
- Puppeteer Documentation
- CDP Viewer
- Puppeteer-core API## Dynamic Path Resolution (v0.4.75+)
When VS Code extensions update, their installation path changes (e.g., from ivgdesign.devmirror-0.4.72 to ivgdesign.devmirror-0.4.75), breaking any hardcoded paths in package.json scripts.
DevMirror uses a stable shim file that remains at the same location and dynamically resolves the current extension path:
Workspace Root
└── .vscode/
└── devmirror/
├── cli.js (or cli.cjs for ESM) # Stable shim
└── config.json # Current paths
- On Extension Activation: Creates/updates the shim and config
- Shim Script: Reads config.json to find current CLI path
- Package.json: Uses relative path to stable shim location
- Result: Scripts survive extension updates
- Detects
"type": "module"in package.json - Creates
.cjsshim for ESM packages - Creates
.jsshim for CommonJS packages
- Calculates relative paths from each package.json to workspace root
- Works with nested package.json files
- Maintains cross-platform compatibility
DevMirror v0.4.82 | GitHub | Issues | VS Code Marketplace
Capture 100% of browser console output with Chrome DevTools Protocol
v0.4.82