Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/puppeteer_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const skipThirdPartyRequests = async opt => {
if (request.url().startsWith(basePath)) {
request.continue();
} else {
request.abort();
request.abort('blockedbyclient');
}
});
};

/**
* @param {{page: Page, options: {sourceMaps: boolean}, route: string, onError: ?function }} opt
* @param {{page: Page, options: {sourceMaps: boolean}, route: string, onError: ?function, basePath: string }} opt
* @return {void}
*/
const enableLogging = opt => {
Expand All @@ -44,6 +44,9 @@ const enableLogging = opt => {
Promise.all(msg.args().map(errorToString)).then(args =>
console.log(`💬 console.log at ${route}:`, ...args)
);
} else if (text.includes('ERR_BLOCKED_BY_CLIENT') && options.skipThirdPartyRequests === true &&
msg.location() && !msg.location().url.startsWith(basePath)) {
// pass -- do not log errors from requests blocked by skipThirdPartyRequests
} else {
console.log(`️️️💬 console.log at ${route}:`, text);
}
Expand Down Expand Up @@ -232,7 +235,8 @@ const crawl = async opt => {
onError: () => {
shuttingDown = true;
},
sourcemapStore
sourcemapStore,
basePath
});
beforeFetch && beforeFetch({ page, route });
await page.setUserAgent(options.userAgent);
Expand Down