Back

Http Request large JSON Response incompleted

  • 0
  • Self Hosted
elemin67
30 May, 2023, 01:08

I try to recive a large json response from eyternal graphQL, but I recive alwais the same issiue.

TypeScript
ERROR Error: Uncaught (in promise): SyntaxError: Unterminated string in JSON at position 999958
SyntaxError: Unterminated string in JSON at position 999958 

My code looks like that:

TypeScript
  async graphQl(body) {
    const response = await fetch(url, {
      method: 'POST',
      headers: this.headers,
      body: JSON.stringify(body),
    });
    if (response.ok) {
      return await response.json();
    } else {
      throw new Error('GraphQL request failed: ' + response.status);
    }
  }

and

TypeScript
  try {
    const body = {
      query: req.payload,
    };
    console.log("body", body)
    let responseQL = await graphQl(body)
    res.send(JSON.stringify(responseQL));
  } catch (error) {
    res.json({ error: error });
  }
TL;DR
The user is having an issue with receiving a large JSON response from an external GraphQL server. The error "Uncaught (in promise): SyntaxError: Unterminated string in JSON at position 999958" is encountered. The code provided shows the use of the fetch API to make the request and handle the response. The issue seems to be related to the response being truncated due to a maximum response limit set by Appwrite functions. One suggestion is to try using the storage API instead for such large responses. Solution: Consider using the storage API instead of Appwrite functions for large JSON responses to avoid truncation.
elemin67
30 May, 2023, 01:13

I checked server-side. And with Postman I dont have any problem on the external graphQL Server

Drake
30 May, 2023, 02:12

There is a maximum response for Appwrite functions. After that, the data is truncated.

elemin67
30 May, 2023, 11:10

Is there a possibility to change it?

Drake
30 May, 2023, 13:03

Not without modifying the source code. For such a large response, maybe you can use the storage API instead

Drake
30 May, 2023, 13:05

I think the next version of functions might remove the limit

elemin67
30 May, 2023, 13:49

That would be great, Do you know when the next Version will be released?

Drake
30 May, 2023, 16:19

some time this year πŸ˜… hard to say for sure. we're actively working on it, though

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more