Skip to content
Merged
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
25 changes: 20 additions & 5 deletions packages/actor-scraper/web-scraper/src/internals/crawler_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,25 @@ export class CrawlerSetup implements CrawlerSetupOptions {
// Set log level early to prevent missed messages.
if (input.debugLog) log.setLevel(log.LEVELS.DEBUG);

// Keep this as string to be immutable.
this.rawInput = JSON.stringify(input);
// Both are sent into the page, where the site's own scripts can read them, so secrets stay out.
// The input is kept as a string to be immutable.
this.rawInput = JSON.stringify({
...input,
initialCookies: undefined,
proxyConfiguration: undefined,
// Hooks run only in Node and often set cookies.
preNavigationHooks: undefined,
postNavigationHooks: undefined,
});
this.env = Object.assign(Actor.getEnv(), {
token: null,
proxyPassword: null,
inputSecretsPrivateKeyFile: null,
inputSecretsPrivateKeyPassphrase: null,
// A development run serves DevTools there, with no authentication.
containerUrl: null,
webServerUrl: null,
});

// Attempt to load page function from disk if not present on input.
tools.maybeLoadPageFunctionFromDisk(input, dirname(fileURLToPath(import.meta.url)));
Expand All @@ -111,7 +128,6 @@ export class CrawlerSetup implements CrawlerSetupOptions {
if (!Actor.isAtHome()) tools.checkInputOrThrow(input, SCHEMA);

this.input = input;
this.env = Actor.getEnv();

// Validations
this.input.pseudoUrls.forEach((purl) => {
Expand Down Expand Up @@ -443,7 +459,7 @@ export class CrawlerSetup implements CrawlerSetupOptions {
* the data returned from the `pageFunction`.
*/
private async _requestHandler(crawlingContext: PuppeteerCrawlingContext) {
const { request, response, page, crawler, proxyInfo } = crawlingContext;
const { request, response, page, crawler } = crawlingContext;
const start = process.hrtime();
const pageContext = this.pageContexts.get(page)!;

Expand All @@ -470,7 +486,6 @@ export class CrawlerSetup implements CrawlerSetupOptions {
browserHandles: pageContext.browserHandles,
pageFunctionArguments: {
request,
proxyInfo,
response: {
status: response && response.status(),
headers: response && response.headers(),
Expand Down
Loading