Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browsertrix-crawler",
"version": "1.12.0",
"version": "1.12.1",
"main": "browsertrix-crawler",
"type": "module",
"repository": "https://github.com/webrecorder/browsertrix-crawler",
Expand Down
10 changes: 5 additions & 5 deletions src/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ export class Crawler {
}

// if automatically restarts on error exit code,
// exit with 0 from fatal by default, to avoid unnecessary restart
// otherwise, exit with default fatal exit code
// exit with 0 from fatal always, to avoid unnecessary restart
// otherwise, exit with provided fatal exit code
if (this.params.restartsOnError) {
logger.setDefaultFatalExitCode(0);
logger.setOverrideFatalExitCode(0);
}

return this.crawlState;
Expand Down Expand Up @@ -986,12 +986,12 @@ self.__bx_behaviors.selectMainBehavior();
if (this.params.failOnContentCheck) {
await page.exposeFunction(
BxFunctionBindings.ContentCheckFailed,
(reason: string) => {
async (reason: string) => {
// if called outside of awaitPageLoad(), ignore
if (!opts.data.contentCheckAllowed) {
return;
}
void this.crawlState.setFailReason(reason);
await this.crawlState.setFailReason(reason);
logger.fatal(
"Content check failed, failing crawl",
{ reason },
Expand Down
13 changes: 8 additions & 5 deletions src/util/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ class Logger {
excludeContexts: LogContext[] = [];
defaultLogContext: LogContext = "general";
crawlState?: RedisCrawlState | null = null;
fatalExitCode: ExitCodes = ExitCodes.Fatal;
overrideFatalExitCode: ExitCodes | null = null;

setDefaultLogContext(value: LogContext) {
this.defaultLogContext = value;
}

setDefaultFatalExitCode(exitCode: number) {
this.fatalExitCode = exitCode;
setOverrideFatalExitCode(exitCode: number) {
this.overrideFatalExitCode = exitCode;
}

setOutputFile(filename: string) {
Expand Down Expand Up @@ -256,11 +256,14 @@ class Logger {
message: string,
data = {},
context: LogContext = this.defaultLogContext,
exitCode = ExitCodes.Success,
exitCode = ExitCodes.Fatal,
) {
this.logAsJSON(`${message}. Quitting`, data, context, "fatal");

void this.setStatusAndExit(exitCode || this.fatalExitCode, "interrupted");
void this.setStatusAndExit(
this.overrideFatalExitCode ?? exitCode,
"failed",
);
}

async closeLog() {
Expand Down
Loading