eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.14k stars 468 forks source link

QoS 0 still accesses localStorage #196

Open benswinburne opened 5 years ago

benswinburne commented 5 years ago

This comment suggests that using QoS 0 would prevent the use of localStorage.

if the network connection or browser fails. If you do not wish for the Local Storage to be used, please do not use this client, or only use QoS 0 to send and receive messages.

However, when using QoS 0 I still receive an exception about access to localStorage being denied in Chrome; it works in Firefox.

Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

I am loading my code into an iframe on another webpage on a separate domain which perhaps has something to do with it. That said however, it'd be useful if using QoS 0 actually prevented the use of localStorage as it's not necessary. Looking at the code here, that's not the case.

It seems that this PR https://github.com/eclipse/paho.mqtt.javascript/pull/191 would indirectly fix my issue as the Exception would no longer crash my application, but doesn't address the fact that QoS 0 doesn't disable localStorage usage.