Skip to content

fix: use json-with-bigint instead of built-in JSON methods in order to properly support int64's#798

Merged
wolfy1339 merged 9 commits into
mainfrom
wolfy1339-patch-1
Feb 20, 2026
Merged

fix: use json-with-bigint instead of built-in JSON methods in order to properly support int64's#798
wolfy1339 merged 9 commits into
mainfrom
wolfy1339-patch-1

Conversation

@wolfy1339

@wolfy1339 wolfy1339 commented Feb 18, 2026

Copy link
Copy Markdown
Member

Resolves #797


Before the change?

  • Used JSON.parse() and JSON.stringify() which cannot handle BigInt

After the change?

  • Use the json-with-bigint package

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@wolfy1339 wolfy1339 added the Type: Bug Something isn't working as documented label Feb 18, 2026
@octokit

octokit Bot commented Feb 18, 2026

Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

Initialize text variable for JSON response handling.
Comment thread src/fetch-wrapper.ts Outdated
Comment thread src/fetch-wrapper.ts Outdated
Comment thread src/fetch-wrapper.ts Outdated
@jenseng

jenseng commented Feb 18, 2026

Copy link
Copy Markdown

Unfortunately json() doesn't support bigint yet either (see whatwg/fetch#104):

new Response('{"id":3804004623172239366}')).json().then(({id}) => console.log(id))
// 3804004623172239400

So in the meantime something like json-bigint will probably be needed

edit: json-bigint is just an example, there are other options. it's the most popular, but appears unmaintained. so it would be good to look at other options, e.g. https://github.com/Ivan-Korolenko/json-with-bigint or https://github.com/josdejong/lossless-json

@wolfy1339 wolfy1339 changed the title Refactor JSON response handling in fetch-wrapper fix: use json-with-bigint instead of built-in JSON.parse() in order to properly support int64's Feb 18, 2026
@wolfy1339 wolfy1339 marked this pull request as ready for review February 18, 2026 03:10
@wolfy1339

Copy link
Copy Markdown
Member Author

I made the changes necessary, this should in theory work

@jenseng jenseng left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looks great, just one suggestion (though it could come as a separate PR)

Comment thread src/fetch-wrapper.ts Outdated
@jenseng

jenseng commented Feb 18, 2026

Copy link
Copy Markdown

also the PR summary needs a tweak since it still says Uses the .json() method on the response object

@wolfy1339 wolfy1339 changed the title fix: use json-with-bigint instead of built-in JSON.parse() in order to properly support int64's fix: use json-with-bigint instead of built-in JSON methods in order to properly support int64's Feb 18, 2026
@wolfy1339 wolfy1339 merged commit f13f5d9 into main Feb 20, 2026
8 checks passed
@wolfy1339 wolfy1339 deleted the wolfy1339-patch-1 branch February 20, 2026 20:20
@github-project-automation github-project-automation Bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active Feb 20, 2026
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 10.0.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

released Type: Bug Something isn't working as documented

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[BUG]: Loss of integer precision in API responses

3 participants