Hi, i created one web app and wanted to create react native app with the same database. When i typed all the ids and code, i got this error. I checked the code multiple times and it is alright, checked the web app, when i used some commands, collection got updated. I thought that its because there are 2 apps on the same project as a free tier, so i created new one but i get the same mistake. I use free tier. Can anybody help asap?
#[AppwriteException: Already read]
30 messages · Page 1 of 1 (latest)
Hello @lusty iron, can you share what you're trying to do and the code where the error happens?
Also, how are you accessing your db, are you using fetch, Appwrite's SDK, or another method?
This is how im getting data
useEffect(() => {
const timeoutId = setTimeout(async () => {
if (searchQuery.trim()) {
await loadMovies();
// Call updateSearchCount only if there are results
if (movies?.length! > 0 && movies?.[0]) {
await updateSearchCount(searchQuery, movies[0]);
}
} else {
reset();
}
}, 500);
return () => clearTimeout(timeoutId);
}, [searchQuery]);
What's the full error and network request being made? Would be curious what the response is from that request as well.
This is the full error message, this updateSearchCount is suposed to update one filed, also when i tried this one for trending movies i get this error. Also, this console.log of response after listDocuments in first function is not even rendering
I mean i even looked at the code i am practicing and its the same, so i dont know if it has to do something with the account
this is the source code
AppwriteException: Failed to execute 'json' on 'Response': body stream already read
at Client.<anonymous> (http://localhost:8081/node_modules/expo-router/entry.bundle?platform=web&dev=true&hot=false&transform.routerRoot=app:93006:17)
at Generator.throw (<anonymous>)
at rejected (
and bold await at getTrendingMovies
This is the error i get on rendering view if trending movies exist (from getTrendingMovies)
The error is literal, you can only read a response stream only once. Try adding logging to see where the duplicate reads are.
what version of the react native SDK do you have?
if it's 0.7.1, can you try to force your app to use 0.7.0?
It worked like yesterday on another app, same principle
did you see my questions?
I ran into this same issue today. Changing the react-native-appwrite package to 0.7.0 fixed the issue. I was on 0.7.1
I was getting the same error as the others above and forcing the app to use version 0.7.0 does fix the issue.
Yes that is because they have removed "async" from function header in 7.0.1. I was about to snatch my head off yesterday, trying to debug because I was receiving the exact same error. I don't know how to call these functions when they're not set as async...
0.7.1
What's Changed
1, remove titles from method descriptions.
2. remove unnecessary asyncs and awaits.
3. fix AppwriteException response type to always be a string
Thank you so much! Changing the react-native-appwrite package to 0.7.0 fixed the issue for me too. I don't understand why they removed the async/await. If somone has the explanation, it would be welcomed
This is indeed a bug welcomed in 0.7.1. Took me a few hours to debug, but going back to 0.7.0 fixed it for me.
Happened with using OAuth for me
I think because you need to set it instead of the SDK adding it automatically?
cc @earnest marsh
@dawn oasis What do you mean by 'to set it'? I don't see any part of the documentation related to this. Or I missed something?
From what I understand, you need to specify async in the main function, then await in the appwrite SDK function call
This is the way async/await works... only with 0.7.0 version of appwrite-react-native. I don't understand your point...
if you look at the sdk code, you will see most of the functions at the end use a call function at the end, which is coming from client.ts file. that function is using async and await
rest of the functions just return the promise returned by this function. hence async awaits there were basically unnecessary
you can still use the SDK same way as you used to, since they still return the same promise
some of our community members found having async awaits like these can have some amount of affect on performance. i remember a benchmark which improved times by around 0.1sec
not a lot, still made sense to make the change
hope that made sense! TLDR nothing should be changed on ur side 😄
sorry if the error confused you, having async awaits removed did not introduce this issue. we have a fix ready just awaiting to be released 🙏