Firebase Firestore onSnapshot PayloadTooLargeError: request entity too large on Expo / React Native project

Viewed 2888

I have Expo / React Native project that subscribes to listen Firestore collection updates. I updated Expo SDK from 39 to 40 and onSnapshot callback function started to throw 'PayloadTooLargeError: request entity too large' when it gets called. I have not updated documents in collection nor I have changed code. Firebase version is, "firebase": "7.9.0" and I didn't update it when upgrading Expo SDK.

Does anyone know what causes this and how to fix?

I subscribe to collection updates like this

  componentDidMount = () => {

//Subscribe for collection changes
const unSubscribeUpdates = this.unsubscribe = db.collection("test_collection")
.onSnapshot({includeMetadataChanges: false}, this.onTestCollectionChanged).bind(this);
 
//Subscribe for favourite changes
const unSubscribeFavouriteUpdates = this.unsubscribe = db.collection("favourites")
.doc(Firebase.auth().currentUser.uid)
.onSnapshot({includeMetadataChanges: false},this.onFavouritesChanged).bind(this);

this.setState({ collection_items: items, favourites:favourites, unSubscribeUpdates: unSubscribeUpdates, unSubscribeFavouriteUpdates:unSubscribeFavouriteUpdates });

and listeners are like this

  onFavouritesListChanged = (doc) => {
    console.log("onFavouritesListChanged for user :" + Firebase.auth().currentUser.uid);
.....

  onVideoListChanged = (snapshot) => {
    console.log("onVideoListChanged");
    console.log("videos length " + this.state.videos.length);

This is the error

onVideoListChanged
PayloadTooLargeError: request entity too large at readStream (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/@expo/dev-server/node_modules/raw-body/index.js:155:17) at getRawBody (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/@expo/dev-server/node_modules/raw-body/index.js:108:12) at read (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/@expo/dev-server/node_modules/body-parser/lib/read.js:77:3) at jsonParser (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/@expo/dev-server/node_modules/body-parser/lib/types/json.js:135:5) at call (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/connect/index.js:239:7) at next (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/connect/index.js:183:5) at serveStatic (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/serve-static/index.js:75:16) at call (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/connect/index.js:239:7) at next (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/connect/index.js:183:5) at call (/Users/nnn/.nvm/versions/node/v14.15.4/lib/node_modules/expo-cli/node_modules/connect/index.js:248:3)

2 Answers

It turned out that this was not issue in Expo but instead in NodeJs 14 when printing too long string into console.log output.

It is the warning of the cnosole.log output

Related