ask-web-fetch 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efa999aac8d4321c2e8e6d463ace6c3f5ec5e95a62973ad06593c4714e1ffab1
4
- data.tar.gz: 9a9e59e8da81bb4238bf1a08b0ba84634553dfd3caac99763a7bb52a54d9ac6e
3
+ metadata.gz: 3ad48d09aa8869b4193a703ad6a760753c2767c9e26a6919b1405a5fb186c7a4
4
+ data.tar.gz: 52960016a3d4740f4913d4879cbf80edacf95e4ffc07601e6dde0d80515ffe81
5
5
  SHA512:
6
- metadata.gz: af1e312f91b9e5ea72679b7e877232cc3e4e9639b3fdf3e98291810377a450a5ce180bb4664ca651c8ccd2084220632890da92fe4eaf8c1ca472e6ba464d60ff
7
- data.tar.gz: 3951989986d476f6bc008712e6451ccb148c9fbe33537544061486d15c79443e0368dd668ef40b35287173ad41f569fc519130a9cb5368e78da16eafbcdf2c91
6
+ metadata.gz: fa6d778abc6918bb7ae839d4f9c96dafe215014a8b2f4efc8027ab1e49d287e3ca57204f54f013531e38dff7393ac23f6da9619b3afd48efae8b6f7e42dfa0d9
7
+ data.tar.gz: 7d4e5fe0e70b28cc3349ec96d071d4e1cc7a46c2c21ca8f41c35968d8b15221854c2418fc72ae2a8e56e97c07930592b2ee5b79da921c4a4ccb4fe6990c7e938
@@ -96,6 +96,12 @@ module Ask
96
96
  browser_mutex.synchronize { @browser ||= build_browser }
97
97
  end
98
98
 
99
+ # Drops the shared browser so the next use builds a fresh
100
+ # session — called when the current one died mid-fetch.
101
+ def reset_browser
102
+ browser_mutex.synchronize { @browser = nil }
103
+ end
104
+
99
105
  def content_filter
100
106
  @content_filter ||= ContentFilter.default
101
107
  end
@@ -162,7 +168,17 @@ module Ask
162
168
 
163
169
  page = self.class.browser.create_page
164
170
  fetch_attempt(page, url)
165
- rescue Ferrum::TimeoutError, Ferrum::ProcessTimeoutError, Ferrum::DeadBrowserError => e
171
+ rescue Ferrum::DeadBrowserError => e
172
+ # The shared browser died mid-fetch (the browserless server
173
+ # killed the session's browser). A dead browser is transient —
174
+ # the next session starts a fresh one — so reconnect and retry
175
+ # ONCE instead of failing the page (observed 2026-08-14: the
176
+ # server's session limits killed browsers and pages were
177
+ # silently dropped).
178
+ self.class.reset_browser
179
+ page = self.class.browser.create_page
180
+ fetch_attempt(page, url)
181
+ rescue Ferrum::TimeoutError, Ferrum::ProcessTimeoutError => e
166
182
  raise TimeoutError, "#{e.class}: #{e.message}"
167
183
  rescue Ferrum::StatusError => e
168
184
  raise FetchError, "browser could not load #{url}: #{e.message}"
@@ -63,7 +63,7 @@ module Ask
63
63
  # and keeps a partial page from ever being stored as the real
64
64
  # thing. Two detectors: known framework markers, or a large
65
65
  # HTML page with almost no server-rendered text.
66
- if js_app_shell?(body) && page[:content].length < SHELL_CONTENT_THRESHOLD
66
+ if js_app_shell?(body) && page[:content].length < SHELL_DEFER_THRESHOLD
67
67
  raise EmptyContentError,
68
68
  "JS-app shell at #{url} — server HTML renders only #{page[:content].length} chars; a rendering backend is required"
69
69
  end
@@ -82,10 +82,19 @@ module Ask
82
82
  # specific footprints of React/Vue/Next/Nuxt app shells.
83
83
  JS_APP_SHELL_MARKERS = /id=["'](?:root|app|__next|site-content)["']|__NEXT_DATA__|window\.__NUXT__|ng-app|data-reactroot/
84
84
 
85
- # Markdown below this from a JS-app shell is "server sent a shell",
86
- # not "page is genuinely short" — a real page (even a short one)
87
- # is usually server-rendered above this. Tunable; the chain turns
88
- # the signal into "prefer Browser for this URL".
85
+ # A framework marker (React/Vue/Next) alone is NOT emptiness: a
86
+ # marked page can server-render real content (careers.abb job
87
+ # pages: 2,162 chars of job description) and must be stored as-is
88
+ # when the rendering backends cannot do better dropping it lost
89
+ # real pages (2026-08-14). The shell deferral fires only when the
90
+ # extraction is genuinely little: below this, the page is a true
91
+ # shell (airbnb: 613KB HTML -> 143 chars). Tunable; the chain
92
+ # turns the signal into "prefer Browser for this URL".
93
+ SHELL_DEFER_THRESHOLD = 500
94
+
95
+ # The ratio detector's own bar, kept for compatibility with the
96
+ # comment below (large HTML + near-empty text is a shell whatever
97
+ # the framework).
89
98
  SHELL_CONTENT_THRESHOLD = 4_000
90
99
 
91
100
  # A page whose server HTML is large but yields almost no text is a
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module WebFetch
5
- VERSION = '0.7.1'
5
+ VERSION = '0.7.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-web-fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 4.0.3
174
+ rubygems_version: 4.0.18
175
175
  specification_version: 4
176
176
  summary: Web fetch library for the ask-rb ecosystem
177
177
  test_files: []