Repository navigation
fix(browser): resolve Playwright Chromium launch failure (#4060) - #4066
Merged
Merged
Conversation
… to Node.js/Express (#4062) Replace outdated uvicorn (Python) configuration with current Node.js/Express implementation. Update environment variables, ExecStart command, restart policy, and file paths to match actual deployment. Uses EnvironmentFile for configuration instead of hardcoded values. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…e starts (#4060) Three root causes fixed: 1. Env var name mismatch: systemd service used HEADLESS_MODE but playwright-server.js reads process.env.HEADLESS, causing it to always evaluate as undefined (truthy for headless) regardless of the headless_mode config value. Fixed playwright.service.j2 to set HEADLESS={{ headless_mode | lower }}, consistent with the .env template. 2. Duplicate route/function registrations: ensureNavPage, captureNavScreenshot, /status, /navigate, /screenshot, /back, /forward, and /reload were all registered twice. The second block (Issue #1120 section) was an accidental duplicate of the first block (lines 81-188) that survived a refactor. Removed the duplicate block entirely. 3. Opaque error logging: initBrowser catch logged the error object as JSON which serializes to {"name":"Error"} with no message. Fixed to log error.message and stack. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4060 - Playwright Chromium browser fails to launch after service starts.
Three root causes identified and fixed:
Env var name mismatch (primary cause): The systemd service unit set
HEADLESS_MODE={{ headless_mode }}butplaywright-server.jsreadsprocess.env.HEADLESS !== 'false'. SinceHEADLESSwas never set, it evaluated toundefined !== 'false'=true, forcing headless mode regardless of theheadless_modeAnsible variable. When the service was deployed withheadless_mode: false(the default), the browser was expected to run headed against the VNC DISPLAY but actually ran headless — and on WSL2 without a proper X11 display configured for headless Chromium, the launch failed. Fixedplaywright.service.j2to setHEADLESS={{ headless_mode | lower }}, consistent with the.envtemplate that has always used the correct variable name.Duplicate route/function registrations:
ensureNavPage,captureNavScreenshot, and five routes (/status,/navigate,/screenshot,/back,/forward,/reload) were all registered twice. The second block (labeled "Persistent navigation page for BrowserTool Issue fix(browser): SLM browser tool broken - missing backend routes and worker endpoints #1120") was an accidental duplicate left over from a prior refactor. In Node.js, the secondfunctiondeclaration silently overwrites the first; in Express, both route handler callbacks are registered and the first one runs. This caused the first (correct) set of handlers to run while the dead second set stayed in memory. Removed the entire duplicate block.Opaque error logging:
logger.error('Failed to launch browser:', error)serialized the Playwright error object viaJSON.stringify, producing{"name":"Error"}with no diagnostic detail. Changed to logerror.messageanderror.stackso the real Chromium failure reason appears in the journal.Files changed
autobot-browser-worker/playwright-server.js— fix error logging, remove 101-line duplicate route blockautobot-slm-backend/ansible/roles/browser/templates/playwright.service.j2— setHEADLESS(notHEADLESS_MODE) with lowercase valueTest plan
journalctl -u autobot-playwrightshows "Browser launched successfully" on startupcurl http://<browser-host>:3000/healthreturnsbrowser_connected: trueheadless_mode: false, confirmHEADLESS=falseappears insystemctl show autobot-playwright --property=Environmentheadless_mode: true, confirm browser launches headless with no DISPLAY dependency🤖 Generated with Claude Code