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 more meaningful error message for Apify.setValue() for large objects

Jan Curn3c468a0ed4d2
diff --git a/src/actor.js b/src/actor.js
index 3e95237ff..95a299aa7 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -249,6 +249,10 @@ export const setValue = (key, value, options, callback = null) => {
// Format JSON to simplify debugging, the overheads with compression is negligible
value = JSON.stringify(value, null, 2);
} catch (e) {
+ // Give more meaningful error message
+ if (e.message && e.message.indexOf('Invalid string length') >= 0) {
+ e.message = 'Object is too large';
+ }
throw new Error(`The "value" parameter cannot be stringified to JSON: ${e.message}`);
}
if (value === undefined) {