Skip to content

Commit

Permalink
more type fixes, follow-up to #488
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Mar 8, 2024
1 parent 3b6c11d commit d09c746
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
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

0 comments on commit d09c746

Please sign in to comment.