Skip to content

fix(Google Drive Node): Fix infinite pagination loop in v1 API request (backport to release-candidate/2.15.x)#28268

Merged
BerniWittmann merged 1 commit intorelease-candidate/2.15.xfrom
backport-28244-to-release-candidate/2.15.x
Apr 10, 2026
Merged

fix(Google Drive Node): Fix infinite pagination loop in v1 API request (backport to release-candidate/2.15.x)#28268
BerniWittmann merged 1 commit intorelease-candidate/2.15.xfrom
backport-28244-to-release-candidate/2.15.x

Conversation

@n8n-assistant
Copy link
Copy Markdown
Contributor

@n8n-assistant n8n-assistant Bot commented Apr 9, 2026

Description

Backport of #28244 to release-candidate/2.15.x.

Checklist for the author (@BerniWittmann) to go through.

  • Review the backport changes
  • Fix possible conflicts
  • Merge to target branch

After this PR has been merged, it will be picked up in the next patch release for release track.

Original 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

  1. Set up a Google Drive trigger node in specificFile mode polling a Google account with many files
  2. Verify the trigger polls correctly without memory growth
  3. 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)

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Architecture diagram
sequenceDiagram
    participant Trigger as Google Drive Trigger
    participant Helpers as GenericFunctions (v1)
    participant Auth as OAuth2 Helper
    participant Google as Google Drive API

    Note over Trigger,Google: Polling Flow for >100 Files

    Trigger->>Helpers: googleApiRequestAllItems()
    
    loop Pagination Loop
        Helpers->>Auth: googleApiRequest(method, endpoint, query)
        Auth->>Google: GET /drive/v3/files (with current pageToken)
        Google-->>Auth: 200 OK (files[], nextPageToken)
        Auth-->>Helpers: responseData
        
        Helpers->>Helpers: Push items to returnData array
        
        alt responseData.nextPageToken exists
            Helpers->>Helpers: CHANGED: Update query.pageToken = responseData.nextPageToken
            Note right of Helpers: Before fix, this update was missing,<br/>causing an infinite loop on page 1.
        else No nextPageToken
            Note right of Helpers: Loop terminates
        end
    end

    Helpers-->>Trigger: return consolidated file list
    Trigger->>Trigger: Process file changes
Loading

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Bundle Report

Bundle size has no change ✅

Affected Assets, Files, and Routes:

view changes for bundle: editor-ui-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/worker-*.js 2.93MB 2.95MB 21929.4% ⚠️
assets/worker-*.js -2.93MB 13.37kB -99.55%
assets/expression-*.js -17 bytes 209 bytes -7.52%
assets/expression-*.js 6 bytes 226 bytes 2.73%
assets/expression-*.js 11 bytes 220 bytes 5.26% ⚠️

@BerniWittmann BerniWittmann merged commit 4d91dff into release-candidate/2.15.x Apr 10, 2026
116 of 123 checks passed
@BerniWittmann BerniWittmann deleted the backport-28244-to-release-candidate/2.15.x branch April 10, 2026 06:23
@n8n-assistant n8n-assistant Bot mentioned this pull request Apr 10, 2026
@n8n-assistant
Copy link
Copy Markdown
Contributor Author

n8n-assistant Bot commented Apr 10, 2026

Got released with n8n@2.15.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation:backport n8n team Authored by the n8n team node/improvement New feature or request Released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant