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

InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase' #503

Open
pedromcunha opened this issue Mar 13, 2019 · 19 comments
Open
Assignees

Comments

@pedromcunha
Copy link

I noticed in our error tracker I get these errors roughly 50/hour.

Error · Uncaught (in promise): InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Error: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. at Promise (https://cdn.onesignal.com/sdks/OneSignalPageSDKES6.js?v=150701:1:42046)

It's happening 100% of the time on all versions of Chrome (Mac and Windows), for anonymous and logged in users of our web app. Any idea what's happening here?

@rgomezp rgomezp self-assigned this Mar 13, 2019
@pedromcunha
Copy link
Author

Any update on this @rgomezp ?

@jkasten2
Copy link
Member

@pedromcunha We have only seen this error if you clear your browser data (either as a whole or specifically for your site).

Are you able to reproduce the issue in any other cases? If so can you provide the full steps to reproduce and a full stack trace?

Thanks.

@rgomezp
Copy link
Contributor

rgomezp commented Apr 18, 2019

Closing due to inactivity

@rgomezp rgomezp closed this as completed Apr 18, 2019
@connetcom
Copy link

I guess the question is why is the error not caught within the OneSignal code itself (as opposed to a js console error) and if such occurs why is there no error handling provided to the user and particularly to the back end OneSignal server to remove the user from the OneSignal active or subscribed users so that they can restart the process from the client side

@rgomezp
Copy link
Contributor

rgomezp commented Apr 29, 2019

We have made a note of this issue internally and plan to fix it in the future. Thanks for your input

@Paxarik
Copy link

Paxarik commented Jul 23, 2019

Hey! any updates about this bug? I've got the same one, in case user first visit the site we've got this issue, in other cases everything is fine.

@rgomezp rgomezp reopened this Jul 23, 2019
@rgomezp
Copy link
Contributor

rgomezp commented Jul 30, 2019

Thanks for your patience while we resolve

@rgomezp
Copy link
Contributor

rgomezp commented Aug 7, 2019

@Paxarik , @connetcom , @pedromcunha ,
I'm not sure exactly where the error is coming from. Could you provide a stack trace of the error? Also please turn on logging using OneSignal.log.setLevel('trace') so we can have the full context

@connetcom
Copy link

in running my own PWA with DB and service worker, i notice this error in my own code which occasionally occurs after i do a reset storage and then restart the PWA. The issue for me occurs when the DB is created and then the datastore is attempted to be accessed but the datastore has not finished being created yet (is all async). Maybe this is something to look at - i.e., the timing of the access to a data store or putting some promise or something to make sure the datastore is created before access.

@rgomezp
Copy link
Contributor

rgomezp commented Aug 12, 2019

@connetcom ,
Thanks for the details. This is a rare error so it seems like it is only happening in certain setups. Do you suspect this is related to your app being PWA?

@connetcom
Copy link

connetcom commented Aug 15, 2019

Sorry for late reply, so, in a sense, yes it has to do with the PWA and more particularly with the testing of the PWA because it only occurs when the DB gets recreated after i manually do a clear storage in the debugger. As said, i am not quite sure but i believe it has to do with the Async nature of how the calls to the DB are made and a lot seems to be going on when the PWA is coming up which might (?) cause some delays. Also, it would seem certainly possible to code around this (which i assume that the onesignal code does not and i have not gotten around to doing myself but did think about a bit and certainly seems feasible) by not attempting to use the datastore until the DB has actually completed the creation of the datastore (would seem some promise could handle this). So, I have not really had an issue with it in the production code but knowing that it can happen on my test system does not give a warm fuzzy about the likelihood of it never happening in production. I would say that OneSignal should spend the time to resolve it.

@rgomezp
Copy link
Contributor

rgomezp commented Aug 15, 2019

@connetcom ,
We haven't ever heard of this happening in a case other than after clearing data. And even then, this should be resolved as soon as a new tab is opened. If you have reproduced this outside of the one case, please let us know. Otherwise, this isn't something we are considering as a top priority.

@rgomezp
Copy link
Contributor

rgomezp commented Sep 23, 2019

Closing due to no response

@jmadler
Copy link
Contributor

jmadler commented Nov 23, 2020

See update in #716 -- let's try to get a min-reproducible.

@jmadler
Copy link
Contributor

jmadler commented Nov 23, 2020

See also update in #671

@OneSignal OneSignal unlocked this conversation Nov 23, 2020
@devpato
Copy link
Contributor

devpato commented Jan 24, 2021

@rgomezp Hi! this issue happens on a ReactJS app (Google Chrome, MacOS) as well. Please consider that a final user can clear the cache but not necessary open a new tab which will result on devtools showing InvalidStateError: Failed to execute 'transaction' on 'IDBDatabase' maybe in the future the users will open a new tab but there's a high change they don't do it the first time.

The React code I'm working on is not a PWA nor has an DB connection besides the one from OneSignal. The React app is just a demo app I'm creating for an article I'm writting

@naudej
Copy link

naudej commented May 21, 2021

Hi!

So this issue also happened when we cleared out the cache and local storage for our PWA built on Angular 9. Is there any remedies or fixes to stop this from happening?

OneSignalBug

@jcardus
Copy link

jcardus commented Nov 7, 2022

I'm also having this issue, i get it on sentry

@GalahadXVI
Copy link

GalahadXVI commented Jun 3, 2024

Same here. Happens even when doing absoutely nothing (not adding in any javascript at all).

Looks to be caused solely by the service worker which is
importScripts("https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js");

Completely clearing data does nothing. Reproducable every time.

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

10 participants