Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rxdb-premium and react-native-sqlite-2 in expo #4497

Closed
meabed opened this issue Mar 1, 2023 · 23 comments
Closed

rxdb-premium and react-native-sqlite-2 in expo #4497

meabed opened this issue Mar 1, 2023 · 23 comments

Comments

@meabed
Copy link

meabed commented Mar 1, 2023

Hi,
Rxdb premium fails with react-native-sqlite-2

it only with with https://github.com/ospfranco/react-native-quick-sqlite - ( but react-native-quick-sqlite fails on android / expo )

There is a typing issue ( setPragma ) and it through unknown unhandled error in syncing.

@meabed meabed changed the title expo: rxdb-premium, expo-sqlite or react-native-sqlite-2 expo: rxdb-premium and react-native-sqlite-2 Mar 1, 2023
@meabed meabed changed the title expo: rxdb-premium and react-native-sqlite-2 rxdb-premium and react-native-sqlite-2 in expo Mar 1, 2023
@pubkey
Copy link
Owner

pubkey commented Mar 1, 2023

Does it fail on iOS, on android or both?
Is there any error message?

@meabed
Copy link
Author

meabed commented Mar 1, 2023

On iOS, the error is unhandled exception in ..... index.js it couldn't create the collection for relocation.

The 13 Rxdb is working fine ReactNative SQLite2 with the updated expo.

I think the plug-ins is not

@pubkey
Copy link
Owner

pubkey commented Mar 1, 2023

Can you enable the logging?

const storage = getRxStorageSQLite({
  sqliteBasics: getSQLiteBasicsCapacitor(sqlite, Capacitor),
  // pass log function
  log: console.log.bind(console)
});

@meabed
Copy link
Author

meabed commented Mar 1, 2023

Yes sure,
the first issue is typing:
image

@meabed
Copy link
Author

meabed commented Mar 1, 2023

the error with log looks like this:

 WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not a function
TypeError: undefined is not a function
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:216896:15)
    at ?anon_0_ (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:216956:35)
    at next (native)
    at asyncGeneratorStep (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:4638:26)
    at _next (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:4657:29)
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:4662:14)
    at tryCallTwo (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:61:9)
    at doResolve (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:216:25)
    at Promise (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:82:14)
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:4654:25)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:216959:28)
    at tryCallOne (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/Users/distiller/react-native/sdks/hermes/build_iphonesimulator/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:29738:26)
    at _callTimer (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:29657:17)
    at _callReactNativeMicrotasksPass (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:29687:17)
    at callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:29850:44)
    at __callReactNativeMicrotasks (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:2787:46)
    at anonymous (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:2599:45)
    at __guard (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:2771:15)
    at flushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:2598:21)
    at invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.mobile.app:2592:33)
 DEBUG  7:55:58 PM | DEBUG : [RxDB] Cannot create todo replication, dbName or todo collection is not available


@pubkey
Copy link
Owner

pubkey commented Mar 1, 2023

Does your premium version differ from your rxdb version?

@meabed
Copy link
Author

meabed commented Mar 1, 2023

it's the same "14.1.2"

I will try to remove all the data and install it again.

@pubkey
Copy link
Owner

pubkey commented Mar 1, 2023

I think I found the error. Let me release a new version.

@pubkey
Copy link
Owner

pubkey commented Mar 1, 2023

I released 14.1.3, please try it out.

@meabed
Copy link
Author

meabed commented Mar 1, 2023

Thank you trying it now.

@meabed
Copy link
Author

meabed commented Mar 1, 2023

The typing issue is fixed:

The create collection issue still persist:

 LOG  ## RxStorage SQLite log: open(0) insights-db-v5-62dbc263c1b40d5fcdb6be31
 LOG  ## RxStorage SQLite log: open(0) DONE
 LOG  ## RxStorage SQLite log: setPragma(1) {"key":"synchronous","value":"normal"}
 LOG  ## RxStorage SQLite log: open(2) todo-db-v6-62dbc263c1b40d5fcdb6be31
 LOG  ## RxStorage SQLite log: open(2) DONE
 LOG  ## RxStorage SQLite log: setPragma(3) {"key":"synchronous","value":"normal"}
 WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not a function
TypeError: undefined is not a function

@pubkey
Copy link
Owner

pubkey commented Mar 2, 2023

Sorry for the inconvenience.
Please try out the latest version 14.1.5

I am working on having everything tested in the CI but running iOS is hard to configure.

@meabed
Copy link
Author

meabed commented Mar 2, 2023

Thank you 🙏

Still failing, the error log is:

 LOG  ## RxStorage SQLite log: setPragma(1) ERROR
 ERROR  1:59:47 PM | ERROR : [RxDB] error creating collections
{
  "_websqlDatabase": {
    "version": "1.0",
    "_db": {
      "_name": "todo-db-v6-62dbc263c1b40d5fcdb6be31"
    },
    "_txnQueue": {
      "length": 0
    },
    "_running": true,
    "_currentTask": {
      "readOnly": false
    }
  },
  "_error": null,
  "_complete": true,
  "_runningTimeout": false,
  "_sqlQueue": {
    "length": 0
  },
  "_running": false
}
WARN  Possible Unhandled Promise Rejection (id: 0):
WebSQLTransaction {
  "_complete": true,
  "_error": null,
  "_running": false,
  "_runningTimeout": false,
  "_sqlQueue": Queue {
    "first": undefined,
    "last": undefined,
    "length": 0,
  },
  "_websqlDatabase": WebSQLDatabase {
    "_currentTask": null,
    "_db": SQLiteDatabase {
      "_name": "todo-db-v6-62dbc263c1b40d5fcdb6be31",
    },
    "_running": false,
    "_txnQueue": Queue {
      "first": undefined,
      "last": undefined,
      "length": 0,
    },
    "version": "1.0",
  },
}

@pubkey
Copy link
Owner

pubkey commented Mar 2, 2023

While reproducing, I stumpled across this problem so it will take me a while to reproduce. Which react-native version are you using?

I found that WebSQL logs errors differently, so the error log that you have posted, contains the transaction objects, not the errors. I will make a new release shortly which fixes that.

@meabed
Copy link
Author

meabed commented Mar 2, 2023

I am using latest 0.71.3 - I don't think it is that issue.
The old version of rxdb and pouchdb is working on same setup ( the only change is rxdb )

@pubkey
Copy link
Owner

pubkey commented Mar 2, 2023

I released 14.1.8 which fixes the error logs and might also fix the error itself.

@meabed
Copy link
Author

meabed commented Mar 2, 2023

Thank you - got the error now:

 LOG  ## RxStorage SQLite log: run(1) ERROR
 LOG  open transaction error (will retry):
 LOG  {"name":"Error","message":"Error code 1: cannot start a transaction within a transaction","stack":"Error: Error code 1: cannot start a transaction within a transaction\n    at anonymous (http://localhost:8081/index.bun

@pubkey
Copy link
Owner

pubkey commented Mar 3, 2023

@meabed I found the root cause and I am working on it. I will update you when it is fixed. This will take some days because I have to improve the CI to add tests for WebSQL.

@meabed
Copy link
Author

meabed commented Mar 3, 2023

Thank you so much @pubkey appreciate it. let me know if i can help in anyway.

@pubkey
Copy link
Owner

pubkey commented Mar 4, 2023

I released version 14.1.9 with a fix, please try.
This is unit tested against the websql library.
It does not use the WebSQL API but instead accesses the internal sqlite object. ._db and uses the exec() method from there.
I tried to rewrite everything so that it is compatible with the browser WebSQL API but this is not possible at the moment because of how WebSQL transactions work.

@meabed
Copy link
Author

meabed commented Mar 4, 2023

@pubkey I just tested and it works 🚀
I will do more testing to make sure all operations working as expected!
Thank you

@pubkey
Copy link
Owner

pubkey commented Mar 4, 2023

Great. I am closing this. If you find any more problems, please @ me so I can see it.

@pubkey pubkey closed this as completed Mar 4, 2023
@jwallet
Copy link
Contributor

jwallet commented Mar 9, 2023

@meabed hey there. how did you make it work with expo? can you tell me on which versions you are? sdk, expo, react-native and react-native-sqllite2 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants