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.

Fixed process exit codes to work in Docker, removed logging

Jan Curna246f80c03ba
diff --git a/package.json b/package.json
index 2ee07124e..820a01a6d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "apifier",
- "version": "0.0.28",
+ "version": "0.0.29",
"description": "Apifier runtime for JavaScript",
"main": "build/index.js",
"keywords": [
diff --git a/src/actor.js b/src/actor.js
index 0954f0f4d..671a9f3ef 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -137,7 +137,7 @@ export const main = (userFunc) => {
console.error(message);
console.error(err.stack || err);
exited = true;
- console.log(`Exiting with code: ${exitCode}`);
+ // console.log(`Exiting with code: ${exitCode}`);
process.exit(exitCode);
};
diff --git a/src/constants.js b/src/constants.js
index 01ba007c3..9cd7643cf 100644
--- a/src/constants.js
+++ b/src/constants.js
@@ -1,13 +1,15 @@
/**
* Exit codes for the act process.
+ * The error codes must be in range 1-128, to avoid collision with signal exits
+ * and to ensure Docker will handle them correctly!
*/
export const EXIT_CODES = {
SUCCESS: 0,
- ERROR_USER_FUNCTION_THREW: 1001,
- ERROR_GETTING_INPUT: 1002,
- ERROR_SETTING_OUTPUT: 1003,
- ERROR_UNKNOWN: 1004,
+ ERROR_USER_FUNCTION_THREW: 91,
+ ERROR_GETTING_INPUT: 92,
+ ERROR_SETTING_OUTPUT: 93,
+ ERROR_UNKNOWN: 94,
};
/**
diff --git a/test/actor.js b/test/actor.js
index bd80328bb..d62c3ea47 100644
--- a/test/actor.js
+++ b/test/actor.js
@@ -439,7 +439,7 @@ describe('Apifier.main()', () => {
throw new Error('Test exception I');
},
context: {},
- exitCode: 1001,
+ exitCode: 91,
});
});
@@ -454,7 +454,7 @@ describe('Apifier.main()', () => {
});
},
context: {},
- exitCode: 1001,
+ exitCode: 91,
});
});
@@ -465,7 +465,7 @@ describe('Apifier.main()', () => {
defaultKeyValueStoreId: 'test storeId',
input: {},
},
- exitCode: 1002,
+ exitCode: 92,
mockInputException: new Error('Text exception III'),
});
});
@@ -478,7 +478,7 @@ describe('Apifier.main()', () => {
context: {
defaultKeyValueStoreId: 'test storeId',
},
- exitCode: 1003,
+ exitCode: 93,
mockOutputException: new Error('Text exception IV'),
});
});
@@ -494,7 +494,7 @@ describe('Apifier.main()', () => {
context: {
defaultKeyValueStoreId: 'test storeId',
},
- exitCode: 1003,
+ exitCode: 93,
});
});
});