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.

Catch only ENOENT errors

Ondra Urbandc3ae47097d8
diff --git a/src/key_value_store.js b/src/key_value_store.js
index 30c31b25c..965260722 100644
--- a/src/key_value_store.js
+++ b/src/key_value_store.js
@@ -275,7 +275,10 @@ export class KeyValueStoreLocal {
const filePath = this._getPath(fileName);
return handler(filePath)
.then(returnValue => ({ returnValue, fileName }))
- .catch(() => null);
+ .catch((err) => {
+ if (err.code === 'ENOENT') return null;
+ throw err;
+ });
})
.then((results) => {
// Using filter here to distinguish between no result and undefined result. [] vs [undefined]