feat(scrapeURL/fire-engine): explicitly delete job after scrape
This commit is contained in:
@@ -17,6 +17,7 @@ import { ActionError, EngineError, SiteError, TimeoutError, UnsupportedFileError
|
|||||||
import * as Sentry from "@sentry/node";
|
import * as Sentry from "@sentry/node";
|
||||||
import { Action } from "../../../../lib/entities";
|
import { Action } from "../../../../lib/entities";
|
||||||
import { specialtyScrapeCheck } from "../utils/specialtyHandler";
|
import { specialtyScrapeCheck } from "../utils/specialtyHandler";
|
||||||
|
import { fireEngineDelete } from "./delete";
|
||||||
|
|
||||||
// This function does not take `Meta` on purpose. It may not access any
|
// This function does not take `Meta` on purpose. It may not access any
|
||||||
// meta values to construct the request -- that must be done by the
|
// meta values to construct the request -- that must be done by the
|
||||||
@@ -44,6 +45,13 @@ async function performFireEngineScrape<
|
|||||||
while (status === undefined) {
|
while (status === undefined) {
|
||||||
if (errors.length >= errorLimit) {
|
if (errors.length >= errorLimit) {
|
||||||
logger.error("Error limit hit.", { errors });
|
logger.error("Error limit hit.", { errors });
|
||||||
|
fireEngineDelete(
|
||||||
|
logger.child({
|
||||||
|
method: "performFireEngineScrape/fireEngineDelete",
|
||||||
|
afterErrors: errors,
|
||||||
|
}),
|
||||||
|
scrape.jobId,
|
||||||
|
);
|
||||||
throw new Error("Error limit hit. See e.cause.errors for errors.", {
|
throw new Error("Error limit hit. See e.cause.errors for errors.", {
|
||||||
cause: { errors },
|
cause: { errors },
|
||||||
});
|
});
|
||||||
@@ -74,6 +82,13 @@ async function performFireEngineScrape<
|
|||||||
error instanceof ActionError ||
|
error instanceof ActionError ||
|
||||||
error instanceof UnsupportedFileError
|
error instanceof UnsupportedFileError
|
||||||
) {
|
) {
|
||||||
|
fireEngineDelete(
|
||||||
|
logger.child({
|
||||||
|
method: "performFireEngineScrape/fireEngineDelete",
|
||||||
|
afterError: error,
|
||||||
|
}),
|
||||||
|
scrape.jobId,
|
||||||
|
);
|
||||||
logger.debug("Fire-engine scrape job failed.", {
|
logger.debug("Fire-engine scrape job failed.", {
|
||||||
error,
|
error,
|
||||||
jobId: scrape.jobId,
|
jobId: scrape.jobId,
|
||||||
@@ -105,6 +120,13 @@ async function performFireEngineScrape<
|
|||||||
status.content = Buffer.from(content, "base64").toString("utf8"); // TODO: handle other encodings via Content-Type tag
|
status.content = Buffer.from(content, "base64").toString("utf8"); // TODO: handle other encodings via Content-Type tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fireEngineDelete(
|
||||||
|
logger.child({
|
||||||
|
method: "performFireEngineScrape/fireEngineDelete",
|
||||||
|
}),
|
||||||
|
scrape.jobId,
|
||||||
|
);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user