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

lib/bugsnag/middleware/rack_request: early load session for Rails 4 #149

Closed
wants to merge 5 commits into from

Conversation

kyrylo
Copy link
Contributor

@kyrylo kyrylo commented Aug 27, 2014

Fixes #144 (#144)

Context: rails/rails#10813

@snmaynard
Copy link
Contributor

Why have you removed the comments?

@kyrylo
Copy link
Contributor Author

kyrylo commented Aug 27, 2014

Because the code is self-descriptive.

P.S. It's not ready to merge, because example-apps fail.

@snmaynard
Copy link
Contributor

Thats a code style thing and your personal opinion. Add them back in please.

@kyrylo
Copy link
Contributor Author

kyrylo commented Aug 27, 2014

Sure, no problem! Added them back.

@kyrylo
Copy link
Contributor Author

kyrylo commented Aug 27, 2014

@ConradIrwin
Copy link
Contributor

Nice! Exactly the kind of bug that the example apps are good at finding.

# Rails 4
notification.add_tab(:session, session.to_hash) if session.loaded?
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyrylo Why do we need to check if the session is loaded given that we already load it? What happens if you just call session.to_hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that API very well, it's just to be sure that we don't pass gibberish.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't just write code like this and assume it's going to work. Could you please do some reading and testing and work out what we actually need to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove if session.loaded?, then potentially, we can get a NoMethodError: undefined method to_hash'. I just realised that I should add session.respond_to?(:loaded?)` to avoid this.

Anyway, what I propose it to write it like this:

notification.add_tab(:session, session.to_hash) if session.respond_to?(:to_hash)

I assume that since the time of the creation of that code the session object has always been a Hash here. So if it's not a Hash, then it's probably a Rails 4 session.

The worst that can happen is that the session tab won't be included at all.

@kyrylo
Copy link
Contributor Author

kyrylo commented Aug 27, 2014

Closed in favour of #152.

@kyrylo kyrylo closed this Aug 27, 2014
@kyrylo kyrylo deleted the 144-fix-sessions branch August 27, 2014 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rails 4 sessions appear in custom tab
3 participants