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 bug in node json with string more than 500mb #19821

Closed
wants to merge 4 commits into from

Conversation

lexich
Copy link

@lexich lexich commented Sep 13, 2021

Problem

For big response It can happen error Error: Cannot create a string longer than 0x1fffffe8 characters

Summary of Changes

Add library @discoveryjs/json-ext for parsing response from arrayBuffer with chunks not more the 100mb.
It works right now, but I've made a PR discoveryjs/json-ext#7 for supporting typings for typescript.

Fixes #

@mergify mergify bot added the community Community contribution label Sep 13, 2021
@mergify mergify bot requested a review from a team September 13, 2021 09:28
@lexich lexich marked this pull request as draft September 13, 2021 09:29
@jstarry
Copy link
Member

jstarry commented Sep 13, 2021

Is it really necessary that web3 supports responses this large?

@lexich
Copy link
Author

lexich commented Sep 13, 2021

Is it really necessary that web3 supports responses this large?

Yes we have cases in https://github.com/metaplex-foundation/metaplex

@jstarry
Copy link
Member

jstarry commented Sep 13, 2021

Is it really necessary that web3 supports responses this large?

Yes we have cases in https://github.com/metaplex-foundation/metaplex

Can you please elaborate? 0.5GB is crazy big

@t-nelson
Copy link
Contributor

Can you please elaborate? 0.5GB is crazy big

This. The default JSON reply buffer is 15MB max (which is also crazy big)

@lexich
Copy link
Author

lexich commented Sep 14, 2021

const { Connection } = require('@solana/web3.js');
const METADATA_PROGRAM_ID = 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s';
const conn = new Connection('https://api.metaplex.solana.com/', 'recent');
const args = conn._buildArgs([METADATA_PROGRAM_ID], undefined, 'base64');
const resp = conn._rpcRequest('getProgramAccounts', args);
resp.then(e => console.log('OK'), err => console.log(err));
/*
> Error: Cannot create a string longer than 0x1fffffe8 characters
    at Buffer.toString (buffer.js:777:17)
    at /.../node_modules/node-fetch/lib/index.js:284:18
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async ClientBrowser.callServer (/.../node_modules/@solana/web3.js/lib/index.cjs.js:2745:20) {
  code: 'ERR_STRING_TOO_LONG'
*/

@vercel
Copy link

vercel bot commented Sep 14, 2021

@lexich is attempting to deploy a commit to the Solana Team on Vercel.

A member of the Team first needs to authorize it.

@lexich lexich marked this pull request as ready for review September 14, 2021 19:45
@lexich
Copy link
Author

lexich commented Sep 21, 2021

@jstarry What do you think about it?

@jstarry
Copy link
Member

jstarry commented Sep 21, 2021

@jstarry What do you think about it?

I still don't think it's necessary and you haven't provided a reason for why you need this

@stale
Copy link

stale bot commented Oct 2, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Oct 2, 2021
@austbot
Copy link

austbot commented Oct 8, 2021

Is it really necessary that web3 supports responses this large?

Yes we have cases in https://github.com/metaplex-foundation/metaplex

Can you please elaborate? 0.5GB is crazy big

@lexich @jstarry I know this PR is labeled stale, but I do agree we should actually fix this at the filtering level, return 500mb to web3 clients is perhaps too much. I'm working on adding correct filters to the getProgramAccounts calls in metaplex.

@stale stale bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Oct 8, 2021
@jstarry
Copy link
Member

jstarry commented Oct 10, 2021

Is it really necessary that web3 supports responses this large?

Yes we have cases in https://github.com/metaplex-foundation/metaplex

Can you please elaborate? 0.5GB is crazy big

@lexich @jstarry I know this PR is labeled stale, but I do agree we should actually fix this at the filtering level, return 500mb to web3 clients is perhaps too much. I'm working on adding correct filters to the getProgramAccounts calls in metaplex.

Sounds great!

@jstarry jstarry closed this Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants