antoniopresto / react-native-local-mongodb

react-native local mongodb storage.
MIT License
303 stars 66 forks source link

Possible unhandled promise rejection (Row too big to fit into CursorWindow) #81

Closed xh-lin closed 6 months ago

xh-lin commented 6 months ago

Hi, I'm getting this console warning, does anyone know why and how to resolve it?

image

my code:

  const itemsPromises = [];

  for (const [itemId, item] of pediaEx.items) {
    itemsPromises.push(
      itemsDb.insertAsync({
        key: itemId,
        val: item,
      }),
    );
  }

  await Promise.all(itemsPromises).then((docs) => {
    console.log(`items added ${docs.length} docs`);
  });
antoniopresto commented 6 months ago

Row too big to fit into CursorWindow is an error on Android's side. The best I can tell is that you can change the storage used.

antoniopresto commented 6 months ago

@xh-lin, maybe the promises are throwing before await Promise.all....

Try:

await Promise.all(
  pediaEx.items.map(async ([itemId, item]) => {
    return itemsDb.insertAsync({
      key: itemId,
      val: item,
    });
  }),
).then((docs) => {
  console.log(`items added ${docs.length} docs`);
});
antoniopresto commented 6 months ago

...It might be better to use Promise.allSettled