@crawlee/browser 4.0.0-beta.206 → 4.0.0-beta.208
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.
- package/internals/browser-crawler.js +18 -6
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasicCrawler, browserPoolCookieToToughCookie, ContextPipeline, cookieStringToToughCookie, EnqueueStrategy, NavigationSkippedError, OwnedOrInjected, remainingNavigationWindowMillis, RequestState, RequestThrottledError, resolveBaseUrlForEnqueueLinksFiltering, SessionError, toughCookieToBrowserPoolCookie, validators, } from '@crawlee/basic';
|
|
1
|
+
import { BasicCrawler, browserPoolCookieToToughCookie, ContextPipeline, cookieStringToToughCookie, EnqueueStrategy, NavigationSkippedError, OwnedOrInjected, remainingNavigationWindowMillis, RequestState, ContextPipelineInitializationError, RequestHandlerError, RequestThrottledError, resolveBaseUrlForEnqueueLinksFiltering, SessionError, SessionRetiredError, toughCookieToBrowserPoolCookie, validators, } from '@crawlee/basic';
|
|
2
2
|
import { assertBrowserPoolNotConfigured, CLOUDFLARE_RETRY_CSS_SELECTORS, parseArgument, RETRY_CSS_SELECTORS, schemas, tryAbsoluteURL, } from '@crawlee/utils/internal';
|
|
3
3
|
import { sleep } from '@crawlee/utils';
|
|
4
4
|
import { z } from 'zod';
|
|
@@ -181,13 +181,25 @@ export class BrowserCrawler extends BasicCrawler {
|
|
|
181
181
|
session: crawlingContext.session,
|
|
182
182
|
});
|
|
183
183
|
tryCancel();
|
|
184
|
-
onCleanup(() => {
|
|
184
|
+
onCleanup((failure) => {
|
|
185
185
|
crawlingContext.registerDeferredCleanup(async () => {
|
|
186
|
-
const
|
|
187
|
-
?
|
|
188
|
-
:
|
|
186
|
+
const cause = failure instanceof RequestHandlerError || failure instanceof ContextPipelineInitializationError
|
|
187
|
+
? failure.cause
|
|
188
|
+
: failure;
|
|
189
|
+
// Only tells the pool what to do with the page's browser state - the request's failure, if any, has
|
|
190
|
+
// already been handled. A thrown `SessionError` or a blocked session counts as a block; a session
|
|
191
|
+
// unusable for any other reason is reported as retired. `retire()`/`markBad()` also bump the usage
|
|
192
|
+
// count, so the block check must come first.
|
|
193
|
+
const { session } = crawlingContext;
|
|
194
|
+
const closeReason = cause instanceof SessionError
|
|
195
|
+
? cause
|
|
196
|
+
: session.isBlocked()
|
|
197
|
+
? new SessionError()
|
|
198
|
+
: session.isUsable()
|
|
199
|
+
? undefined
|
|
200
|
+
: new SessionRetiredError();
|
|
189
201
|
await this.browserPool
|
|
190
|
-
.closePage(page, { error })
|
|
202
|
+
.closePage(page, { error: closeReason })
|
|
191
203
|
.catch((closeError) => this.log.debug('Error while closing page', { error: closeError }));
|
|
192
204
|
});
|
|
193
205
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/browser",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.208",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/timeout": "^1.0.1",
|
|
51
|
-
"@crawlee/basic": "4.0.0-beta.
|
|
52
|
-
"@crawlee/browser-pool": "4.0.0-beta.
|
|
53
|
-
"@crawlee/types": "4.0.0-beta.
|
|
54
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
51
|
+
"@crawlee/basic": "4.0.0-beta.208",
|
|
52
|
+
"@crawlee/browser-pool": "4.0.0-beta.208",
|
|
53
|
+
"@crawlee/types": "4.0.0-beta.208",
|
|
54
|
+
"@crawlee/utils": "4.0.0-beta.208",
|
|
55
55
|
"tslib": "^2.8.1",
|
|
56
56
|
"type-fest": "^4.41.0",
|
|
57
57
|
"zod": "^4.5.4"
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "81d3fbc1abd10fd34be2694a98f4a36e2ebc2f64"
|
|
79
79
|
}
|