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

Private browsing issue in Firefox #26

Closed
cyrilletuzi opened this issue Mar 23, 2018 · 13 comments
Closed

Private browsing issue in Firefox #26

cyrilletuzi opened this issue Mar 23, 2018 · 13 comments
Assignees

Comments

@cyrilletuzi
Copy link
Owner

cyrilletuzi commented Mar 23, 2018

Follow up of comments in #20

IndexedDB is disabled in private (Firefox, Edge). Same as pouchdb/pouchdb#5641

Same goes for localStorage.

The lib should detect these cases and fallback to in-memory database.

Note it just has to avoid errors, local storage is useful for apps, where being in private browsing makes no sense.

Help is welcome for up to date information about browser support of IndexedDB and localStorage in private mode, and also for examples of detection for each case. Some seem trivial (like Edge), but some others seem quite difficult and may not be fixable (like Firefox).

@cyrilletuzi
Copy link
Owner Author

A first fix is released in 3.1.3 for browsers like Edge where IndexedDB is undefined.

I'll investigate the cases of browsers where the API are available but not functional. Not sure it will be possible to solve this.

@cyrilletuzi
Copy link
Owner Author

cyrilletuzi commented Mar 24, 2018

So, a summary of my tests in private mode :

indexedDB

  • OK in Chrome and Safari
  • null in IE / Edge (not sure about Edge, maybe it's fixed)
  • API available in Firefox but throwing error on connect()

localStorage

  • didn't see any problem in any browser

Solutions

For IE/Edge, fallback to localStorage (fixed in 3.1.4).

For Firefox, it's an open bug in the browser. It may be resolved soon, and I think this lib can't handle it in the current state. There is the same problem in all other libs managing local storage, and I didn't find any which resolved this issue.

I see only two solutions :

  • do async code in factory provider (not a good idea and probably not possible)
  • switch the provider at runtime (not sure it's possible, and even if it is, it would too much complicate the lib code for just an edge case).

For now, users should catch error if they want to manage this case, and encourage Firefox to fix this issue.

But if someone knows a good solution, feel free to comment.

@cyrilletuzi cyrilletuzi reopened this Mar 24, 2018
@cyrilletuzi cyrilletuzi changed the title Handle private browsing scenarios Private browsing issue in Firefox Mar 30, 2018
@cyrilletuzi
Copy link
Owner Author

Following my request, the priority of the issue in Firefox bug tracker has been raised, so it may be fixed soon.

@cyrilletuzi
Copy link
Owner Author

For info, I tried to fix this issue inside the lib, but it seems impossible to do it in a right way. So we have to wait for Firefox to fix this.

@cyrilletuzi
Copy link
Owner Author

cyrilletuzi commented Jul 27, 2018

@elkozmon @pinalbhatt @hannesrohde I may have find a workaround for Firefox private browsing issue. Could you test in a real app with v6.1.0-beta.0?
npm install @ngx-pwa/local-storage@6.1.0-beta.0

@hannesrohde
Copy link

@cyrilletuzi I just tried it in our app and 6.1.0-beta.0 fixes the issue in Firefox private browsing!
(FWIW it also fixes an issue I observed just on my machine with Firefox in normal browsing mode)

Sorry for the late reply and thank you for having a look and fixing the issue!

@cyrilletuzi
Copy link
Owner Author

@hannesrohde Thanks for testing!

I need to investigate another related issue first, and then it will be released in stable.

@venoby
Copy link

venoby commented Aug 8, 2018

Hi, I got v6.1.0-beta.0
On Firefox for ios works good.
Firefox in private mode on windows has next error:
Invalid data in localStorage.

String set in isFilerRelatedToUser not correct:
image
image 1

@cyrilletuzi
Copy link
Owner Author

@venoby Could you share the code relative to your issue? Invalid data error is when JSON parsing data retrieve from localStorage is wrong. Your example seems to show it has been previously stringified twice.

@cyrilletuzi
Copy link
Owner Author

@venoby Also, check with beta.1 first:
npm install @ngx-pwa/local-storage@6.1.0-beta.1

@venoby
Copy link

venoby commented Aug 9, 2018

@cyrilletuzi Hi again, yep you are right. It was typo error in my code 🙈
6.1.0-beta.1 works fine in my app, thank you

@cyrilletuzi
Copy link
Owner Author

Fixed in 6.1.

@cyrilletuzi
Copy link
Owner Author

For information: after many years, this has finally been fixed in Firefox 115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants