Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional type fixes, follow-up to #488 #489

Merged
merged 1 commit into from Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/crawler.ts
Expand Up @@ -33,7 +33,7 @@ import { Screenshots } from "./util/screenshots.js";
import { parseArgs } from "./util/argParser.js";
import { initRedis } from "./util/redis.js";
import { logger, formatErr } from "./util/logger.js";
import { WorkerState, runWorkers } from "./util/worker.js";
import { WorkerOpts, WorkerState, runWorkers } from "./util/worker.js";
import { sleep, timedRun, secondsElapsed } from "./util/timing.js";
import { collectAllFileSources } from "./util/file_reader.js";

Expand Down Expand Up @@ -869,7 +869,7 @@ self.__bx_behaviors.selectMainBehavior();
await this.checkLimits();
}

async teardownPage({ workerid }: WorkerState) {
async teardownPage({ workerid }: WorkerOpts) {
if (this.screencaster) {
await this.screencaster.stopById(workerid);
}
Expand Down
13 changes: 5 additions & 8 deletions src/util/worker.ts
Expand Up @@ -52,7 +52,7 @@ export async function runWorkers(
}

// ===========================================================================
type WorkerOpts = {
export type WorkerOpts = {
page: Page;
cdp: CDPSession;
workerid: WorkerId;
Expand All @@ -71,9 +71,8 @@ export type WorkerState = WorkerOpts & {
// ===========================================================================
export class PageWorker {
id: WorkerId;
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
crawler: any;

crawler: Crawler;
maxPageTime: number;

reuseCount = 0;
Expand All @@ -97,9 +96,7 @@ export class PageWorker {

constructor(
id: WorkerId,
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
crawler: any,
crawler: Crawler,
maxPageTime: number,
collDir: string,
) {
Expand Down Expand Up @@ -127,7 +124,7 @@ export class PageWorker {
await this.recorder.onClosePage();
}

if (!this.crashed) {
if (!this.crashed && this.opts) {
try {
await timedRun(
this.crawler.teardownPage(this.opts),
Expand Down