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.

1.0 KB
Raw Blame
// https://github.com/apify/crawlee/issues/1732
// https://github.com/apify/crawlee/issues/1710

import { MemoryStorageBackend } from '@crawlee/core';
import type { KeyValueStoreBackend } from '@crawlee/types';

describe('MemoryStorageBackend should not crash when saving a big buffer', () => {
    const storage = new MemoryStorageBackend();

    let store: KeyValueStoreBackend;

    beforeAll(async () => {
        store = await storage.createKeyValueStoreBackend();
    });

    test('should not crash when saving a big buffer', async () => {
        let zip: Buffer;

        if (process.env.CRAWLEE_DIFFICULT_TESTS) {
            const numbers = Array.from([...Array(18_100_000).keys()].map((i) => i * 3_000_000));

            zip = Buffer.from([...numbers]);
        } else {
            zip = Buffer.from([...Array(100_000)].map((i) => i * 8));
        }

        try {
            await store.setValue({ key: 'owo.zip', value: zip });
        } catch (err) {
            expect(err).not.toBeDefined();
        }
    });
});