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.

Added dummy setInterval() to prevent termination of process while awaiting empty promise, bumped package.json version

Jan Curna90a1c55371d
diff --git a/package.json b/package.json
index 472e01a35..a2923daa3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "apify",
- "version": "0.4.6",
+ "version": "0.4.7",
"description": "Apify runtime for JavaScript",
"main": "build/index.js",
"keywords": [
diff --git a/src/actor.js b/src/actor.js
index 3ba2b1cff..34ea9311b 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -214,17 +214,24 @@ export const main = (userFunc) => {
process.exit(exitCode);
};
+ // Set dummy interval to ensure the process will not be killed while awaiting empty promise:
+ // await new Promise(() => {})
+ // Such a construct is used to for testing of act timeouts and aborts.
+ const intervalId = setInterval(_.noop, 9999999);
+
try {
newPromise()
.then(() => {
return userFunc();
})
.catch((err) => {
+ clearInterval(intervalId);
if (!exited) {
exitWithError(err, EXIT_CODES.ERROR_USER_FUNCTION_THREW, 'User function threw an exception:');
}
})
.then(() => {
+ clearInterval(intervalId);
if (!exited) {
process.exit(EXIT_CODES.SUCCESS);
}