react-native-sqlite-storage icon indicating copy to clipboard operation
react-native-sqlite-storage copied to clipboard

Calling SQLite.enablePromise(true) multiple times corrupts the library

Open justinbhopper opened this issue 1 year ago • 0 comments

Expected Behavior

Calling SQLite.enablePromise(true) after its already been called should result in a no-op.

Current Behavior

Calling SQLite.enablePromise(true) more than once will break the library.

Possible Solution

Calling SQLite.enablePromise(true) multiple times will corrupt the library, causing errors such as RangeError: Maximum call stack size exceeded.

The way this method is written, it rewires the methods on the exported SQLite class from callback-based to promise-based. It does not have any safety check for whether this operation has previously already occurred, so the operation ends up rewiring methods a second time, breaking them entirely.

justinbhopper avatar Sep 19 '24 21:09 justinbhopper