Skip to content

Conversation

@angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Jan 30, 2026

Resolves: #435

Description

Fixes an issue where getByType() and similar methods hang indefinitely when using pageSize: 100 combined with fetchLinks on repositories with many documents.

The issue was introduced in v7.19.2 when request deduplication was refactored. Multiple callers sharing a deduplicated request would each try to read from the same response stream, causing hangs with large responses.

The changes in this PR result in ~2x faster responses compared to v7.18 and ~5x faster than v7.19 in the specific scenario detailed in #435.

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

N/A

How to QA 1

  1. Run existing tests: npm test
  2. Manual test with a repository that has 100+ documents:
    const client = prismic.createClient("your-repo")
    const results = await client.getByType("your-type", {
      pageSize: 100,
      fetchLinks: ["linked_type.field1", "linked_type.field2"],
    })

🦥


Note

Medium Risk
Touches the core request/deduplication layer and subtly changes ResponseLike.clone() semantics, which could affect downstream code that relies on independent response streams.

Overview
Fixes deduplicated GET requests so multiple callers don’t compete for the same response body stream.

This wraps deduplicated fetch() responses in a memoizing ResponseLike (memoizeResponse) that caches text(), json(), and blob() reads using clone(), and stops returning response.clone() at the end of request() (returning the memoized wrapper instead).

Written by Cursor Bugbot for commit e5166dc. This will update automatically on new commits. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment.

Replace `response.clone()` with a memoized response wrapper that caches
promises for `text()`, `json()`, and `blob()` reads. This allows multiple
callers sharing a deduplicated request to safely read from the same response
without stream/body handling issues.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Clone the response before reading text/blob to avoid "body already read"
errors when both methods are called on the same memoized response.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getByType() hangs/times out with pageSize and fetchLinks parameters v7.19.2+

3 participants