Skip to content

Conversation

htunnicliff
Copy link
Member

@htunnicliff htunnicliff commented Oct 2, 2025

Changes

Updated fetchUserInfo to appropriately handle GitHub API rate limits.

Notes

This should resolve issues we've encountered in Netlify builds (example).

I'm also going to add a token to our Netlify env vars to help increase our rate limits.

@htunnicliff htunnicliff requested a review from gzm0 October 2, 2025 15:54
@htunnicliff htunnicliff requested a review from a team as a code owner October 2, 2025 15:54
Copy link

changeset-bot bot commented Oct 2, 2025

⚠️ No Changeset found

Latest commit: e9e49ce

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

netlify bot commented Oct 2, 2025

Deploy Preview for openapi-ts ready!

Name Link
🔨 Latest commit e9e49ce
🔍 Latest deploy log https://app.netlify.com/projects/openapi-ts/deploys/68e06a0a91bb0f0008ad27c3
😎 Deploy Preview https://deploy-preview-2471--openapi-ts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

github-actions bot commented Oct 2, 2025

size-limit report 📦

Path Size
packages/openapi-fetch/dist/index.mjs 6.73 KB (0%)

@htunnicliff htunnicliff force-pushed the handle-gh-api-rate-limits branch 3 times, most recently from fd68e4c to a7660f2 Compare October 2, 2025 15:58
@htunnicliff htunnicliff force-pushed the handle-gh-api-rate-limits branch from a7660f2 to 493eee1 Compare October 2, 2025 16:03
Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

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

TY for looking into this.

I've left some comments. All optional. The change is definitely an overall improvement, so we should probably ship it :)


if (process.env.GITHUB_TOKEN) {
request.headers.set('Authorization', `Bearer ${process.env.GITHUB_TOKEN}`)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion to make this non-optional once it is set as secret (or even set the secret right away, so you don't need to touch it anymore, up to you).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think leaving this conditional might make sense just in case, since the API will remain accessible even if we don't have a token(albeit at a more constrained rate limit).


const res = await fetch(request);

if (!res.ok) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Only do the rate-limit retry if we get a 429? (res.status === 429)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Normally I'd concur, but after reading the docs on handling rate limit errors appropriately, I think retrying in this manner should cover us.

}

main();
if (import.meta.main) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Heh :) First time I see this in JS/TS.

Copy link
Member Author

Choose a reason for hiding this comment

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

😄 it's the ESM equivalent of require.main === module

@htunnicliff htunnicliff force-pushed the handle-gh-api-rate-limits branch from 33948b7 to 413ca37 Compare October 3, 2025 16:46
@htunnicliff htunnicliff requested a review from gzm0 October 3, 2025 16:59
@htunnicliff htunnicliff merged commit 6ed0634 into main Oct 4, 2025
14 checks passed
@htunnicliff htunnicliff deleted the handle-gh-api-rate-limits branch October 4, 2025 02:52
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