Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

fix: error when Apify.call does not return OUTPUT (#999)

Ondra Urban935720567985
diff --git a/src/actor.js b/src/actor.js
index 2b2b7bc88..8b8b42b49 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -358,9 +358,16 @@ export const call = async (actId, input, options = {}) => {
let getRecordOptions = {};
if (disableBodyParser) getRecordOptions = { buffer: true };
- const { value: body, contentType } = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT', getRecordOptions);
+ const actorOutput = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT', getRecordOptions);
+ const result = { ...run };
+ if (actorOutput) {
+ result.output = {
+ body: actorOutput.value,
+ contentType: actorOutput.contentType,
+ };
+ }
- return { ...run, output: { contentType, body } };
+ return result;
};
/**
@@ -476,9 +483,16 @@ export const callTask = async (taskId, input, options = {}) => {
let getRecordOptions = {};
if (disableBodyParser) getRecordOptions = { buffer: true };
- const { value: body, contentType } = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT', getRecordOptions);
+ const actorOutput = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT', getRecordOptions);
+ const result = { ...run };
+ if (actorOutput) {
+ result.output = {
+ body: actorOutput.value,
+ contentType: actorOutput.contentType,
+ };
+ }
- return { ...run, output: { contentType, body } };
+ return result;
};
function isRunUnsuccessful(status) {