Skip to content

Bump up op-sqlite version for react native v0.76#37

Merged
craftzdog merged 4 commits into
craftzdog:masterfrom
tearfulDalvik:master
Jan 7, 2025
Merged

Bump up op-sqlite version for react native v0.76#37
craftzdog merged 4 commits into
craftzdog:masterfrom
tearfulDalvik:master

Conversation

@tearfulDalvik

Copy link
Copy Markdown
Contributor

#35

In React Native 0.76.3, createError from pouchdb-errors would throw an exception. To handle this, I catch all errors. However, this causes specific errors like MISSING_DOC to be converted into a more generic error:
Error.stack getter called with an invalid receiver.

You can see the related code here:
core.ts#L343

@craftzdog

Copy link
Copy Markdown
Owner

Thanks for the PR! I will review it when I'm back working on my mobile app

@craftzdog

Copy link
Copy Markdown
Owner

Looks like the Error.stack getter issue has been resolved here:

facebook/hermes#1496 (comment)

But not landed in RN yet?

@craftzdog

Copy link
Copy Markdown
Owner

Patching createError as the following solves the issue:

function createError(error, reason) {
  var err = new PouchError(error.status, error.name, error.message);
  if (reason !== undefined) {
    err.reason = reason;
  }
  return err;
}

@craftzdog

Copy link
Copy Markdown
Owner

Created a PR: apache/pouchdb#9009

@tearfulDalvik

Copy link
Copy Markdown
Contributor Author

Sweet, thank you. Shall we wait for pouchdb to make changes, or should we patch it ourselves

@craftzdog

Copy link
Copy Markdown
Owner

Let's wait for it to be merged.
Could we merge the op-sqlite upgrade part first?

@tearfulDalvik

Copy link
Copy Markdown
Contributor Author

Sure, please proceed

Comment thread src/core.ts Outdated
doc = unstringifyDoc(item.data, metadata.id, item.rev)
doc = unstringifyDoc(item.data as string, metadata.id, item.rev as string)
finish(null)
}).catch(e => {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you revert this 'catching all errors' part?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this catch is important, since it rejects the promise of async execution. If removed, pouchdb.get() will remain unresolved.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean, it is for catching errors thrown from tx.execute?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or tx.execute will hang

@craftzdog

Copy link
Copy Markdown
Owner

hmm, trying to run it locally but it seems that Pods are broken:

[!] CocoaPods could not find compatible versions for pod "React-timing":
  In Podfile:
    React-timing (from `../node_modules/react-native/ReactCommon/react/timing`)

Specs satisfying the `React-timing (from `../node_modules/react-native/ReactCommon/react/timing`)` dependency were found, but they required a higher minimum deployment target.
Failed to update boost. Attempting to update the repo instead.
> pod install --repo-update

...

[!] CocoaPods could not find compatible versions for pod "boost":
  In snapshot (Podfile.lock):
    boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)

  In Podfile:
    boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)

It seems like you've changed the version of the dependency `boost` and it differs from the version stored in `Pods/Local Podspecs`.
You should run `pod update boost --no-repo-update` to apply changes made locally.
Couldn't install: boost. Updating the Pods project and trying again...
Command `pod install --repo-update` failed.
└─ Cause: This is often due to native package versions mismatching. Try deleting the 'ios/Pods' folder or the 'ios/Podfile.lock' file and running 'npx pod-install' to resolve.

will try generating a project with create-react-native-library again

@craftzdog

Copy link
Copy Markdown
Owner

Have you tested replications?

@tearfulDalvik

Copy link
Copy Markdown
Contributor Author

#37 (comment)
That's weird, but it's more of a demo problem, not the library.

I did not test replications, just local transactions.

@craftzdog

Copy link
Copy Markdown
Owner

replications never finish. Maybe another breaking change in RN0.76

@tearfulDalvik

tearfulDalvik commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

It could be another unresolved promise, i.e. an unhandled error in the promise, similar to the createError issue we encountered before.

@craftzdog

Copy link
Copy Markdown
Owner

Yeah, I had to apply the patch to pouchdb-errors both in <ROOT>/node_modules and <ROOT>/examples/node_modules.
PouchDB needs to check the error code as it says:

The above 404 is totally normal. PouchDB is just checking if a remote checkpoint exists.

@craftzdog

Copy link
Copy Markdown
Owner

apache/pouchdb#9028 solved the error issue.

@craftzdog craftzdog merged commit 32e2a18 into craftzdog:master Jan 7, 2025
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

Successfully merging this pull request may close these issues.

2 participants