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

fix: Errors reported from getAllKeys/clear [WINDOWS] #424

Merged

Conversation

chrisglein
Copy link
Contributor

Summary:

On Windows getAllKeys was reporting the correct results, but also an empty array error. Unlike the multi* methods, these expect a single error, not an array of errors.
The fix is to change the type sent by the windows implementation from an array to a single object. That object is also just a null value, since there are no errors being reported currently by the windows implementation.

Test Plan:

Manually validated with the repo's example app on Windows. Also tested by patching to a react-native-windows app that was already using async storage and failing on getAllKeys.

The test app doesn't contain any usage of getAllKeys, which is probably why this was missed.

`getAllKeys` was reporting the correct results, but also an empty array
error. Unlike the multi* methods, these expect a single error, not an
array of errors.
The fix is to change the type sent by the windows implementation from an
array to a single object. That object is also just a null value, since
there are no errors being reported currently by the windows
implementation.
Copy link
Contributor

@kaiguo kaiguo left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@@ -478,7 +478,7 @@ void DBStorage::DBTask::getAllKeys(sqlite3* db) {
void DBStorage::DBTask::clear(sqlite3* db) {
if (Exec(db, m_callback, u8"DELETE FROM AsyncLocalStorage")) {
std::vector<winrt::JSValue> callbackParams;
callbackParams.push_back(winrt::JSValueArray());
callbackParams.push_back(nullptr);
Copy link

Choose a reason for hiding this comment

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

you could pass JSValue::Null or even omit the nullptr altogether

Copy link
Member

Choose a reason for hiding this comment

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

@chrisglein any chance you could take a look on this suggestion?

Copy link

Choose a reason for hiding this comment

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

fwiw this should be non-blocking :)

Copy link
Member

@krizzu krizzu left a comment

Choose a reason for hiding this comment

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

Thanks @chrisglein 💪

Let me know if you're done with PR, so I can merge this

@krizzu
Copy link
Member

krizzu commented Aug 28, 2020

Since this is not a blocker, I'll going ahead and merge it

@krizzu krizzu merged commit b1b5bcf into react-native-async-storage:master Aug 28, 2020
@exotexot
Copy link

exotexot commented Sep 6, 2020

Hello,

while clear() does erase the contents of the AsyncStorage.db file, it does return an Error - literally just printing "Error" in my console. Similar case with getAllKeys() - here, it returns "Error" without returning the keys.

@asklar
Copy link

asklar commented Sep 19, 2020

@exotexot if you're seeing a bug could you please file an issue? Thanks! CC @chrisglein

@chrisglein
Copy link
Contributor Author

I don't believe there's been a release with this fix yet. The latest release was from Aug 17 and this was merged after that. I'm not sure what release schedule the module is on - looks pretty sparse. In the meantime you can patch the source files directly (which is what I did to test the fix).

djhr pushed a commit to smartHelios/async-storage that referenced this pull request Oct 5, 2020
…nc-storage#424)

`getAllKeys` was reporting the correct results, but also an empty array
error. Unlike the multi* methods, these expect a single error, not an
array of errors.
The fix is to change the type sent by the windows implementation from an
array to a single object. That object is also just a null value, since
there are no errors being reported currently by the windows
implementation.
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.

None yet

5 participants