Class: Capybara::Lightpanda::Process
- Inherits:
-
Object
- Object
- Capybara::Lightpanda::Process
- Defined in:
- lib/capybara/lightpanda/process.rb
Constant Summary collapse
- READY_PATTERN =
/server running.*address\s*=\s*(\d+\.\d+\.\d+\.\d+:\d+)/m- ADDRESS_IN_USE_PATTERN =
/err=AddressInUse/- STOP_GRACE_SECONDS =
Seconds to wait for a graceful SIGTERM before escalating to SIGKILL in ‘stop` / the GC finalizer. Lightpanda absorbs a single SIGTERM while a CDP connection is still live (graceful shutdown blocks on the connection worker — see .claude/rules/lightpanda-io.md limitation #7B). The PRIMARY fix is gem-side: Browser closes the CDP WebSocket before SIGTERM at exit (Browser.quit_all via at_exit), so SIGTERM lands after EOF and teardown is instant. This escalation is the BACKSTOP for crash / GC-abandon paths the at_exit can’t reach — without it, a SIGTERM left to the finalizer (which can’t close the WS) blocked Process.wait forever (the 45-min ‘rake test:all` hang). NOT the same as #2507/#2509 (telemetry curl-multi), which the gem never hits because it disables telemetry.
3- MINIMUM_NIGHTLY_BUILD =
Floor for the cookie/navigation/redirect/modal/keyboard/css/forms/dispatch/ xpath/history/iframe-context/dialog fixes the gem now relies on: PR #2255 (Network.clearBrowserCookies empty params + Network.getAllCookies), PR #2257 (window.location.pathname/.search assignment triggers navigation), PR #2265 (URL fragment inherited across fragment-less redirect), PR #2261 (LP.handleJavaScriptDialog pre-arm), PR #2283 (Referer on cross-page nav), PR #2292 (KeyboardEvent.keyCode/charCode), PR #2294 (UA stylesheet display:none for HEAD/SCRIPT/STYLE/NOSCRIPT/TEMPLATE/ TITLE/), PR #2308 (textarea LF→CRLF), PR #2312 (<input type=image> click submits form), PR #2315 (:disabled honors fieldset/ optgroup ancestors), PR #2322 (LP dialog defaultText fallback when promptText is null), PR #2324 (<label> click runs activation behavior on labeled control), PR #2286 (HTML constraint validation API: el.validity, validationMessage, checkValidity, reportValidity), PR #2342 (<summary> click toggles parent <details>.open), PR #2352 (HTMLInputElement.pattern + patternMismatch via V8 RegExp), PR #2368 (events: report listener exceptions instead of halting dispatch — load-bearing for the gem’s JS bundle dispatch assumptions), PR #2289 (Page.getNavigationHistory + Page.navigateToHistoryEntry —lets us drop the history.back()/history.forward() JS workaround in Browser#back / #forward), PR #2305 (XPath 1.0: Document.evaluate, XPathResult, XPathEvaluator, XPathExpression — lets us drop the ~700 LOC XPath polyfill in javascripts/index.js), PR #2431 (cdp: remove duplicate Page.frameNavigated emission + reuse child frame’s V8 context — fixes issue #2400 iframe contextId churn, lets us drop Browser#find_in_frame’s refresh_frame_stack! rescue), PR #2445 (cdp: reset browser context arena on Target.disposeBrowserContext — restores per-spec state hygiene during Driver#reset!, cures the batch-mode pollution that PR #2431 alone exposed), PR #2435 (dom: implement HTMLDialogElement.showModal, close natively — load-bearing for the gem’s HTMLDialogElement assumptions after polyfills.js was deleted), PR #2450 (forms: add enctype + 5 submitter form-* IDL accessors + text/plain submission — lets us delete polyfills.js entirely; reads of form.enctype / submitter.formTarget now return spec-typed values natively), PR #2478 (css: evaluate @media and matchMedia against viewport —inline <style> @media blocks now apply declarations against the hardcoded 1920×1080 viewport, and window.matchMedia(q).matches returns spec-correct booleans. Lets _lightpanda.isVisible detect inline-@media-gated hides via el.checkVisibility() without any gem-side workaround), PR #2487 (css: external <link rel=“stylesheet”> fetch behind the –enable-external-stylesheets flag — build_args now passes that flag unconditionally, so the floor MUST include the build that introduced it; the flag is a fatal UnknownOption on builds < 6353), PR #2498 (StyleManager: author display rule beats UA [hidden] — fixes the Stimulus/Alpine dropdown ElementNotFound), PR #2635 (dom: DOM.setFileInputFiles backs input.files + fires change for <input type=file>) AND PR #2654 (forms: encode file inputs as multipart/form-data on submit — filename + Content-Type + bytes per RFC 7578). Both halves are required for attach_file to upload end-to-end: #2635 populates the FileList, #2654 makes form submission carry the bytes. Node#fill_input’s ‘when “file”` branch calls Browser#set_file_input_files, so the floor MUST include the #2654 build; on builds 6625–6671 the file attaches but the form submits empty. NOTE: the gem’s teardown hang is the live-CDP-connection SIGTERM hang (limitation #7B) — telemetry-independent, present on 6353 AND on the #2509 fix build, handled by the at_exit WS-close plus the SIGKILL backstop above. It is NOT #2507 (telemetry curl-multi, fixed by #2509): the gem disables telemetry, so it never creates the curl multi #2507 needs. Keep both teardown defenses even after #2511 (the variant-B fix, MERGED in build 6371) lands in a nightly. Build 6672 = the #2654 merge (22d1c5ec, 2026-06-08) — the first commit carrying both file-upload halves. PR #2671 (DataTransfer / DataTransferItem / DataTransferItemList + DragEvent, merged 2026-06-10) provides the APIs Node#drop’s DROP_JS assembles its payload from; on builds without it the drop JS raises “DataTransfer is not defined”. Build 6699 = the #2671 merge (d1f4c409, 2026-06-10) — now the binding floor. (The prior 6672 file-upload floor — and 6353 before it — are subsumed.)
Gem::Version.new("6699")
Instance Attribute Summary collapse
-
#nightly_build ⇒ Object
readonly
Returns the value of attribute nightly_build.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#ws_url ⇒ Object
readonly
Returns the value of attribute ws_url.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(options) ⇒ Process
constructor
A new instance of Process.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Process
Returns a new instance of Process.
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/capybara/lightpanda/process.rb', line 100 def initialize() @options = @pid = nil @ws_url = nil @version = nil @nightly_build = nil @stdout_r = nil @stdout_w = nil @stderr_r = nil @stderr_w = nil @finalizer_registered = false end |
Instance Attribute Details
#nightly_build ⇒ Object (readonly)
Returns the value of attribute nightly_build.
98 99 100 |
# File 'lib/capybara/lightpanda/process.rb', line 98 def nightly_build @nightly_build end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
98 99 100 |
# File 'lib/capybara/lightpanda/process.rb', line 98 def pid @pid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
98 99 100 |
# File 'lib/capybara/lightpanda/process.rb', line 98 def version @version end |
#ws_url ⇒ Object (readonly)
Returns the value of attribute ws_url.
98 99 100 |
# File 'lib/capybara/lightpanda/process.rb', line 98 def ws_url @ws_url end |
Instance Method Details
#alive? ⇒ Boolean
135 136 137 138 139 140 141 142 |
# File 'lib/capybara/lightpanda/process.rb', line 135 def alive? return false unless @pid ::Process.kill(0, @pid) true rescue Errno::ESRCH, Errno::EPERM false end |
#start ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/capybara/lightpanda/process.rb', line 113 def start binary_path = @options.browser_path || Binary.update raise BinaryNotFoundError, "Lightpanda binary not found" unless binary_path check_minimum_version(binary_path) attempt_start(binary_path) rescue ProcessTimeoutError => e raise unless e..include?("already in use") kill_process_on_port(@options.port) attempt_start(binary_path) end |
#stop ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/capybara/lightpanda/process.rb', line 127 def stop return unless @pid self.class.send(:terminate, @pid) cleanup_pipes @pid = nil end |