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

Cannot read property 'transaction' of undefined #101

Open
RyanP13 opened this issue Mar 3, 2016 · 4 comments
Open

Cannot read property 'transaction' of undefined #101

RyanP13 opened this issue Mar 3, 2016 · 4 comments
Labels
Milestone

Comments

@RyanP13
Copy link

RyanP13 commented Mar 3, 2016

I am getting this issue in my angular application.

The local forage provider is configured in the config block like so:

            $localForageProvider.config({
                driver: localforage.LOCALSTORAGE,
                name: 'ttn',
                storeName: 'keyvaluepairs'
            });

Once a user is logged in there is a browser refresh timer which triggers on an hourly basis.

When that happens the config block will run again and throw the following error in the localforage JS file because once logged in we try to resolve the logged in user on that route. It seems from localforage JS that in line 1186:

var store = dbInfo.db.transaction(dbInfo.storeName, 'readonly')

The db is not yet defined. When i check that the data is there in local storage from the window object it is definitely stored there.

Is this expected behaviour?

@Caligone
Copy link

Caligone commented May 9, 2016

Same issue here.
It happens when I use $localforage on a promisified resolved service.

@CreatedByVictor
Copy link

Same problem here with a very similar setup to RyanP13.

@RyanP13
Copy link
Author

RyanP13 commented May 25, 2016

For what it is worth i solved this in a hacky way by checking the window.localStorage object to see if my storage key was present. If not found then define the store. Not pretty:

        function configureLocalForage(){

            var isStoreDefined = false;

            for (var key in window.localStorage){
                if(key.match(/^ttn\/[a-z0-9]*/gmi) !== null){
                    isStoreDefined = true;
                }
            }

            if(!isStoreDefined){
                $localForageProvider.config({
                    driver: localforage.LOCALSTORAGE,
                    name: 'ttn',
                    storeName: 'keyvaluepairs'
                });
            }

        }

@scotttrinh scotttrinh added the bug label Jun 15, 2016
@scotttrinh scotttrinh added this to the 1.3.0 milestone Jun 19, 2016
@scotttrinh scotttrinh modified the milestones: 1.3.0, 1.4.0 Jul 2, 2016
@scotttrinh
Copy link
Owner

Can someone make a minimal reproduction case for this? I'm not sure I follow the issue, as I've never seen this in my own usage.

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

No branches or pull requests

4 participants