Infinite pagination loop patched in Google Drive trigger
The Google Drive trigger node was stuck fetching the same page forever whenever a Google account contained more than 100 files, causing memory to balloon until the process crashed. A single missing line meant pagination tokens were checked but never used.
The Google Drive trigger node for n8n contained a subtle but severe bug in its pagination logic. When polling Google Drive for file changes, the function checked whether a next page token existed—but never actually passed that token to subsequent API requests. The result: an infinite loop that fetched the same first page of 100 results repeatedly, accumulating items in memory until the process ran out of memory and crashed.
This bug was isolated to the v1 transport used by the trigger node. The v2 transport used by the main Google Drive node already had the correct implementation, and every other Google API integration—Gmail, Calendar, Sheets, YouTube—implemented pagination correctly. The v1 Drive function was the lone outlier.
Users running Google Drive trigger workflows against accounts with many files would see repeated OOM crashes even when no workflows were triggered. The fix adds a single line that assigns the page token to the query parameters, allowing the loop to advance through results as intended. The loop now terminates properly once all pages have been fetched.
View Original GitHub Description
Summary
Fixes a memory leak in the Google Drive trigger node caused by an infinite pagination loop in the v1 googleApiRequestAllItems function.
The function's do-while loop checked responseData.nextPageToken to decide whether to continue paginating, but never assigned query.pageToken = responseData.nextPageToken to advance to the next page. When the Google Drive API returned more than 100 results (one page), the same first page was re-fetched indefinitely, pushing ~100 items into an array per iteration until OOM.
This bug only affects the v1 transport used by GoogleDriveTrigger.node.ts. The v2 transport (used by the main Google Drive node) already had the correct implementation. Every other Google API pagination function in the codebase (Gmail, Calendar, Sheets, YouTube, etc.) also includes this assignment — the v1 Drive function was the only one missing it.
Impact: Instances with active Google Drive trigger workflows polling accounts with >100 modified files experienced unbounded memory growth and repeated OOM crashes, even when no workflow executions were triggered.
How to test
- Set up a Google Drive trigger node in
specificFilemode polling a Google account with many files - Verify the trigger polls correctly without memory growth
- Run the new unit test:
cd packages/nodes-base && pnpm test nodes/Google/Drive/test/v1/GenericFunctions.test.ts
Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/NODE-4565
Review / Merge checklist
- PR title and summary are descriptive. (conventions)
- Docs updated or follow-up ticket created.
- Tests included.
- PR Labeled with
release/backport(if the PR is an urgent fix that needs to be backported)