Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent infinite loop when fetching a list of results #335

Merged
merged 2 commits into from
Jan 29, 2022

Conversation

threepointone
Copy link
Contributor

When fetching a list of results from cloudflare APIs (e.g. when fetching a list of keys in a kv namespace), the api returns a cursor that a consumer should use to get the next 'page' of results. It appears this cursor can also be a blank string (while we'd only account for it to be undefined). By only accounting for it to be undefined, we were infinitely looping through the same page of results and never terminating. This PR fixes it by letting it be a blank string (and null, for good measure)

@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2022

🦋 Changeset detected

Latest commit: 7862f38

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

When fetching a list of results from cloudflare APIs (e.g. when fetching a list of keys in a kv namespace), the api returns a `cursor` that a consumer should use to get the next 'page' of results. It appears this cursor can also be a blank string (while we'd only account for it to be `undefined`). By only accounting for it to be `undefined`, we were infinitely looping through the same page of results and never terminating. This PR fixes it by letting it be a blank string (and `null`, for good measure)
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Thanks for catching this @threepointone.
Please can you add a test.

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

TESTS! 😻

@threepointone threepointone merged commit a417cb0 into main Jan 29, 2022
@threepointone threepointone deleted the fix-fetchlistresult branch January 29, 2022 16:52
@github-actions github-actions bot mentioned this pull request Jan 29, 2022
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.

2 participants