🛑 The Problem
Right now, if we fetch a repository with 50,000 commits, we attempt to download all 50,000 into a single JavaScript array in memory before inserting them into Postgres. This will cause Node.js to trigger a V8 Fatal Error (Heap Out of Memory) and crash the server.
💡 The Solution
We must stream the data. We need to refactor the ingestion logic to use Async Generators, inserting data into Postgres in chunks of 100, and immediately letting the garbage collector free the memory before fetching the next page.
🛠️ Implementation Details
- Change the fetch function to return an
AsyncGenerator.
- Use
for await (const response of octokit.paginate.iterator(...)).
- Inside the loop, extract the 100 commits from the current page.
- Execute a bulk
INSERT into Drizzle.
yield a progress update (e.g., total processed).
- The loop continues to the next page, allowing V8 to garbage collect the previous page's JSON.
✅ Acceptance Criteria
Ready to tackle this? Comment .take below to get automatically assigned!
🛑 The Problem
Right now, if we fetch a repository with 50,000 commits, we attempt to download all 50,000 into a single JavaScript array in memory before inserting them into Postgres. This will cause Node.js to trigger a V8 Fatal Error (Heap Out of Memory) and crash the server.
💡 The Solution
We must stream the data. We need to refactor the ingestion logic to use Async Generators, inserting data into Postgres in chunks of 100, and immediately letting the garbage collector free the memory before fetching the next page.
🛠️ Implementation Details
AsyncGenerator.for await (const response of octokit.paginate.iterator(...)).INSERTinto Drizzle.yielda progress update (e.g., total processed).✅ Acceptance Criteria
Ready to tackle this? Comment
.takebelow to get automatically assigned!