-
Notifications
You must be signed in to change notification settings - Fork 37
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
getProgramAccounts() large string error #73
Comments
Very interesting. What version of Node is this by the way? @lorisleiva, do you think this is a limitation introduced by our new bigint-aware JSON parser, that's not present in the native parser? |
I use node --version v22.11.0 |
Ugh yeah it is likely that our custom JSON parser — that mitigates This is because we are having to await on As such, we end up hitting the Node limitation on strings which is set at However, that many characters amount to 512Mb of data and perhaps the pros of having safe I say by default because anyone can customise their RPC object by providing custom transports and APIs, which, when dealing with such large amounts of data, might be the best way forward anyway. |
Is this the case, @GustavAlbrecht? Are you downloading >512Mb of data from an RPC? |
Do you think there's any advantage to changing the |
We definitely won't be including something like this in the core library, but you might consider making a custom network transport that either disables our bigint parser, or uses something like https://github.com/karminski/streaming-json-js to convert it to JSON progressively without having to store the entire string. |
To answer your first question: Yes i download more than 512MB. I remember it happened in 2024 that it needed to switch to parsing progressively because stake accounts surpassed the 512 MB limit. For the second question: To clarify i was using I guess in theory an implementation that would parse json text and yield account objects in chunks would be ideal in terms of memory and processing for many use cases. Or at least for my use case where i fetch accounts, send them to the stake account parser, and then persist them in Postgres in batches. Right now i first need to wait until the whole text is parsed into account objects before i can start parsing account.data and persist stake account objects in Postgres. |
Overview
The getProgramAccounts() method call throws and error when used on the Stake program:
Error: Cannot create a string longer than 0x1fffffe8 characters
Steps to reproduce
Edit: I use node --version v22.11.0
Description of bug
The core issue is a node internal limit on string size. I used libraries like stream-json to workaround this. Since getProgramAccounts is expected to sometimes return heavy data i consider it a bug that this library isn't handling heavy data coming from this call.
The text was updated successfully, but these errors were encountered: