Skip to content
This repository has been archived by the owner on Jul 31, 2019. It is now read-only.

Cannot read property 'native' of null. Warnings and errors. #56

Closed
palucdev opened this issue Sep 19, 2016 · 14 comments
Closed

Cannot read property 'native' of null. Warnings and errors. #56

palucdev opened this issue Sep 19, 2016 · 14 comments

Comments

@palucdev
Copy link

palucdev commented Sep 19, 2016

Hello!
I wanted to try out this plugin in my angularJS cordova application. I wrapped plugin methods in simple service and used it in simple cases of setting/getting string value. Everything works fine but console logs a few warnings:
Error in Success callbackId: SecureStorage1208879459 : TypeError: Cannot read property 'native' of null
in cordova.js:312
Also after this, few errors pop:
TypeError: Cannot read property 'native' of null in securestorage.js:387.
All functionality works fine but I want to get rid of this errors and warning. How can I do that?
Currently I'm working on cordova 6.20 and testing app on Android 5.0.2

@ggozad
Copy link
Contributor

ggozad commented Sep 19, 2016

cc @demetris-manikas

@demetris-manikas
Copy link
Contributor

Hi.
Look like there are invalid entries in the storage.
The only reason I can think that could cause such entries would be that an entry in localStorage whose name starts with SS and has not been created by the plugin.
@Darkoon could this be the case?
Can you please clarify whether the errors appeared after upgrading the plugin or the first time you tried it.
Also could you please debug and reply on which key the error happens and what's the value of it?

@palucdev
Copy link
Author

Hello again!
I'm not using localStorage in my project but decided to look at it, my localStorage is empty all the time.
Errors started to pop up from the very beginning and are connected with get method but they appear only once, after first use of get. I tried to test it on few devices and avd's but in all cases there were the same warnings/erros. Clearly I don't know what to do with that, plugin works fine and I really want to use it. Can you tell me something about the structure, where can I possibly find something to fix it? I'm using a few other cordova plugins (only one connected with data storage - sqlite plugin), maybe there are some conflicts between them?
Thanks for help!

@ggozad
Copy link
Contributor

ggozad commented Sep 21, 2016

This shouldn't stop you in anyway, we will have a look into it, but it should not affect the operation of the plugin.
In brief, we used to store encrypted data in localStorage but recently switched to using a native mechanism. There is a migration that happens the first time for those that had been using the old version. This migration fails in your case, but it shouldn't occur at all since it's a pristine installation and there is nothing to migrate.

@palucdev
Copy link
Author

Is there any other information I can provide to help fix this problem?

@demetris-manikas
Copy link
Contributor

@Darkoon If you could provide the name and value of the failing entry it could point us to the right direction. If this is a problem for you I could instruct you on how to do it. Thanks.

@palucdev
Copy link
Author

I don't quiet understand about what entry are you talking (warnings/errors pop up for every key-value pair even for 'mykey', 'myvalue' from readme examples). So if you are talking about something else, please instruct me.

@demetris-manikas
Copy link
Contributor

I am talking about debugging the plugin code. The error happens while migrating old data as ggozad already mentioned. Adding a printout of the key value pair that is being migrated in line 362 of securestorage.js would do the job. You can do the change either by forking this project or by changing the downloaded plugin code.

@palucdev
Copy link
Author

palucdev commented Oct 4, 2016

Sorry for the late response! Log added in line 362 was never called, so I decided to log key and value from line 385. I saw pairs generating warnings/errors, keys: insert, pushArrayand swapare all set to null.

@jmotyl1959
Copy link

Line 387 in www/securestorage.js does not check for a null value returned from JSON.parse and thus throws and exception. I modified that line to read:

if (payload != null && !payload.native) {

and it fixed the problem for me.

@demetris-manikas
Copy link
Contributor

@jmotyl1959 Hey, thanks but you solve the problem by hiding the reason. Can you confirm Darkoon's findings?
@Darkoon thanks for your results I am looking into it.

@demetris-manikas
Copy link
Contributor

@Darkoon @jmotyl1959 Can you please verify that applying the correction I did in my PR fixes the problem? My tests show it does but I 'll wait until you verify. Thanks for the help.

@palucdev
Copy link
Author

@demetris-manikas I can confirm that your correction fixed the problem for me.

@ggozad
Copy link
Contributor

ggozad commented Oct 11, 2016

Fixed in 2.5.2

@ggozad ggozad closed this as completed Oct 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants