Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

accessControl session var goes out of scope? maybe? #37

lefnire opened this Issue Aug 27, 2012 · 10 comments


None yet
4 participants

lefnire commented Aug 27, 2012

Still don't know exactly what's going on, figured I'd file after knowing better the bug - but I just can't figure it out. Using the accessControl boilerplate from README.md (see my own implementation here), this.session resolves as undefined at various times:

TypeError: Cannot read property 'userId' of undefined
    at Object.<anonymous> (/Users/lefnire/Dropbox/tyler/Sites/personal/habitrpg/derby/lib/server/setupStore.js:14:37)
    at guard (/Users/lefnire/Dropbox/tyler/Sites/personal/habitrpg/derby/node_modules/derby/node_modules/racer/lib/accessControl/accessControl.Store.js:156:14)

it seems that maybe this.session goes out of scope? The most common way I can replicate this is by closing my laptop and opening it again - which is pretty edge-case I know - but still it fully crashes the server. However, it does crop up otherwise from time to time.

lefnire commented Aug 27, 2012

racer, derby, racer-db-mongo 0.3.12

lackac commented Aug 27, 2012

This has happened in my app as well. I couldn't find the root cause but my experience is the same. I ended up checking in access control guards whether this.session is defined.

lefnire commented Aug 27, 2012

good thinking, i'll play with that

lefnire commented Sep 7, 2012

thanks @lackac , it seems checks on is defined have no side-effects (thought accessControl might go awry since this is a workaround, but I think we're good). I'll close for now an re-open if issues crop up.

@lefnire lefnire closed this Sep 7, 2012

lackac added a commit to lackac/racer that referenced this issue Sep 8, 2012

lackac commented Sep 8, 2012

This has bitten me eventually. I don't know why exactly, but when I try to access my application from mobile chrome (android or iPad) it keeps reconnecting. I finally found that the cause of it was this guard and the fact that this.session was undefined. What I don't know is why this doesn't happen on desktop, but does on mobile.

I kept debugging this going step by step into the depth of racer – interesting journey, btw. After a few hours of mind wrapping I got to the source of the problem. I have found that the only time this.session was undefined was when the client was making a snapshot request. The code segment linked above is the one which builds the req object in this case and that is the object from where this.session should be coming from. You can see that the session property is missing from the object.

I tried adding it to it and that did solve the issue for me. I have issued a pull request with that change.

lefnire commented Sep 10, 2012

awesome. I'll test your patch soon & chime in.

@lefnire lefnire reopened this Sep 10, 2012

Any news on this?

lefnire commented Dec 1, 2012

no updates on my part. i haven't yet tried removing @lackac's workaround because it works just fine with it in place. should i just close this ticket?

lefnire commented Feb 5, 2013

@lackac's fix codeparty#40 indeed solved the problem. I've been running HabitRPG for a while now, using a the return unless @session and @session.userId workaround suggested above without problems. But for one reason or another, once you have multiple subscriptions on a page it breaks down - @lackac's fix solves this. Would that codeparty pulled requests :(


nateps commented Jun 4, 2013

No longer relevant in 0.5

@nateps nateps closed this Jun 4, 2013

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