Braden1996 / react-native-replicache

Plug-in React Native compatibility bindings for Replicache.
81 stars 5 forks source link

react-native-quick-sqlite - fails with Possible Unhandled Promise Rejection #5

Closed robsoden closed 6 months ago

robsoden commented 1 year ago

I'm attempting to implement the react-native-quick-sqlite package and the replicache instantiation fails, throws the following warning:

WARN  Possible Unhandled Promise Rejection (id: 1):
Error: Did not resolve
Error: Did not resolve

I've been unable to locate the source of it as the stack trace is very generic and all inside core react-native module files

here's my implementation:


import { createReplicacheReactNativeQuickSQLiteExperimentalCreateKVStore } from '@react-native-replicache/react-native-quick-sqlite';
import { Replicache, TEST_LICENSE_KEY } from 'replicache';

export function useReplicache() {
  const r = React.useMemo(
    () =>
      new Replicache({
        licenseKey: TEST_LICENSE_KEY,
        pushURL: `<my test server push url>`,
        pullURL: `<my test server pull url>`,
        experimentalCreateKVStore: createReplicacheReactNativeQuickSQLiteExperimentalCreateKVStore,
        name: 'chat-user-id',
        mutators: {},
      }),
    [],
  );
  return r;
}

here is my package.json dep list:

"dependencies": {
    "@pusher/pusher-websocket-react-native": "^1.2.2",
    "@react-native-community/blur": "^4.3.2",
    "@react-native-community/checkbox": "^0.5.15",
    "@react-native-replicache/react-native-quick-sqlite": "^1.0.0",
    "@react-navigation/bottom-tabs": "^6.5.7",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.12",
    "@react-navigation/stack": "^6.3.16",
    "expo": "^48.0.0",
    "expo-crypto": "~12.2.1",
    "i18next": "^22.5.0",
    "react": "18.2.0",
    "react-dom": "^18.2.0",
    "react-i18next": "^12.3.1",
    "react-native": "0.71.6",
    "react-native-config": "^1.5.1",
    "react-native-gesture-handler": "^2.9.0",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-quick-sqlite": "^8.0.2",
    "react-native-reanimated": "2.14.4",
    "react-native-safe-area-context": "^4.5.0",
    "react-native-screens": "^3.20.0",
    "react-native-svg": "^13.9.0",
    "replicache": "^12.2.2",
    "replicache-react": "^2.11.0"
  },

i've added the expo-crypto polyfill as per the example

any help appreciated! thanks!

robsoden commented 1 year ago

ah, finally figured it out.

react-native-quick-sqlite removed transactionAsync in this commit which was a breaking change from version 8.0.0-beta.2 that was used in this sample project.

downgrading has solved the issue. it might be a simple fix to just change to transaction, will submit a PR if I can prove it out.

Braden1996 commented 1 year ago

ah, finally figured it out.

react-native-quick-sqlite removed transactionAsync in this commit which was a breaking change from version 8.0.0-beta.2 that was used in this sample project.

downgrading has solved the issue. it might be a simple fix to just change to transaction, will submit a PR if I can prove it out.

Hey @robsoden, sorry to hear you had problems! I suspect what you're describing would fix the issue; I'd need to take a deeper look to confirm though.

robsoden commented 1 year ago

hello again!

@Braden1996 some further updates here - even after downgrading and getting the project up and running, I was plagued by frequent "unhandled promise rejection" yellow box warnings where react-native-quick-sqlite would error out due to transaction issues. In additions to the warnings, sometimes the data just wouldn't load from the database to the UI.

I finally went ahead and upgraded to the latest package and replaced the deprecated transactionAsync call in your code and it seems to be very solid now.

I went ahead and submitted a PR if that's helpful! https://github.com/Braden1996/react-native-replicache/pull/6

Thanks again for your work on this package!

Braden1996 commented 1 year ago

Hey @robsoden, thanks for this - super helpful! I'll try take a look this weekend at the PR and hopefully we can get this merged :)

Braden1996 commented 6 months ago

hello again!

@Braden1996 some further updates here - even after downgrading and getting the project up and running, I was plagued by frequent "unhandled promise rejection" yellow box warnings where react-native-quick-sqlite would error out due to transaction issues. In additions to the warnings, sometimes the data just wouldn't load from the database to the UI.

I finally went ahead and upgraded to the latest package and replaced the deprecated transactionAsync call in your code and it seems to be very solid now.

I went ahead and submitted a PR if that's helpful! #6

Thanks again for your work on this package!

Sorry I took so long on this! I've deprecated quick-sqlite in favour of op-sqlite!