vasern / vasern

Vasern is a fast, lightweight and open source data storage for React Native

Home Page:https://vasern.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to write data

apppro123 opened this issue · comments

Error: Unable to write data
at createErrorFromErrorData (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:146)
at C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:95
at MessageQueue.__invokeCallback (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:397)
at C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:127
at MessageQueue.__guard (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:297)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:126)
at debuggerWorker.js:72

Somehow it is working but i get this error message.
I save 4 database with an await in a row. That causes the problem above but i dont know why?

Hi @apppro123, I am unable to diagnose the problem. Can you help to clarify the error? It'd be helpful to have:

  • A screenshot of the error
  • Snipped part of code that the issue appear
  • and Expected behavior

Thank you!

I will write you tomorrow!

Thank you.

Is #19 related to this thread?

No. #19 is just for Android 7 and lower but #18 is in every version.

error message:
Error: Unable to write data
at createErrorFromErrorData (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:146)
at C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:95
at MessageQueue.__invokeCallback (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:397)
at C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:127
at MessageQueue.__guard (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:297)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (C:\Users\kalla\Apps\OwnApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:126)
at debuggerWorker.js:72

snippet of code which is responsible for error (before i insert in every database with .insert({...}, false), so save is false)
await Alarm.save();
await Recurrence.save();
await OtherCalendar1.save();
await CalendarEvent.save();

Expected behaviour no error :)
But as i already mentioned i didnt noticed that this effects the db, everything else works as expected but is fires an error.

@apppro123, were the data successfully inserted?

The error Unable to write data will appear when it doesn't find the document name (for example Calendar or Alarm). Or when calling Calendar.insert without any records.

I should be able to make the error message more clear and prevent calling insert method without any records.

Besides, it is a good practice to wrap code in try catch block when using await. I think it helps manage the error easier. Otherwise, it will throw an error and crash the app.

For example, you can wrap the above code like this:

try {
    await Alarm.save();
    await Recurrence.save();
    await OtherCalendar1.save();
    await CalendarEvent.save();
} catch(error) {
    // console.log(error)
}

(I always try to make my answer clear. Sorry if you find the answer contains things you already know)

Hi @apppro123, have you able to work this out yet?

Yes, i dont get errors any more. So i think it has worked! :)

Thanks for your update! 👍