-
Notifications
You must be signed in to change notification settings - Fork 61
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
Strange intermittent error /w multipart posts #46
Comments
I guess Tmpdir calls |
The error seems to be occurring too early for my application code to get involved. The request and exception are logged by unicorn, but are not present in the rails log. I also added a logging statement in my controller and it isn't reached when the error occurs. I also forgot to add, I don't believe this is specific to unicorn. I have also observed this error with rainbows! and puma. |
Look here: http://www.ruby-doc.org/core-1.9.3/Hash.html#method-c-try_convert It really calls |
It's converting a nil. rack-1.4.5/lib/rack/multipart/parser.rb:104
ruby-1.9.3-p429/lib/tempfile.rb:129
ruby-1.9.3-p429/lib/tmdir.rb:116
to confirm, I modified roar-0.11.18/lib/roar/representer/json.rb:19
And saw this in my logs during some uploads:
The modification seems to work as a band-aid solution |
You know what? I reckon that I will investigate on that, that shouldn't happen. But let me say one thing: if it was your fault you owe me 3 beers at least! |
Ok that is exactly the case - somewhere your singleton instance |
It probably is my fault :( I will have to check all the controllers. oh dear. |
I'm not sure if you have to buy the drinks. The thing is: should roar really extend a singleton object like |
I found the erroneous controller. I'll take responsibility for this one. I understand the concern about magic. But, as you saw, it was a really confusing error and seems worth preventing. My long term plan is to modify my representers to be decorators, which should eliminate entirely the possibility of this occurring again. Additionally, I now check whether or not nil responds to to_hash after every request so I have a better chance of finding future errors. |
Agreed, we should add a check to roar-rails since this is an ugly hard-to-spot thing. Oh cool, so you buy the beers? Great! |
FWIW, this issue just bit us in the rear. As a hack, I am overriding nil.extend to stop this from happening. Not sure it's necessarily an roar-rails issue, but it's a doozy. |
Is the problem that it's trying to represent (render) a |
Well, I am spitting out a message from my #extend, and I see:
I am not sure where this is coming from (I haven't investigated) Then, there's:
Which is ours (PlayerRepresenter) . I haven't been able to reproduce it outside of production yet. but, we were seeing errors like So, yeah, I think something was nil, and we (or a gem) called nil.extend(PlayerReprsenter) so that the next render of a Player called to_hash on nil and BOOM. Again, the fact that I am calling nil.extend is not a roar-rails issue, but I thought I'd add this in case others are seeing such oddities. |
You're passing a |
Actually, in our case, we may explicitly be calling In other words, I think, in our case, this is indicative of something we I don't think Rails is getting involved here. Nick Sutterer wrote:
|
Ok, if you pass a If you extend a |
Hello there, Aaaah, it was my own fault, too. :) |
Thanks! I might open Roar-rails to be "community supported" as I am not interested in supporting "the Rails Way" anymore because it's wrong and misleading people. After the Roar integration with Trailblazer is finished it might be more obvious how wrong things are handled in the "Rails Way" and how much more intuitive it is to structure your code into operations that know which representer to use for which model. Sorry if that doesn't help you! 😜 |
We just ran into this, and I figured I'd share the super dirty way we caught where exactly this was happening. If you overwrite the
it should be pretty obvious when/where this happens. Hope this helps anyone else who runs into this! |
ruby 1.9.3-p429
rails 3.2.13
representable 1.5.3
roar 0.11.18
roar-rails 0.1.0
I'm experiencing a strange intermittent error involving multipart posts. It happens rarely, but once it starts to happen, it keeps happening until the app server is restarted.
My question is, why is Roar::Representer::JSON::InstanceMethods::to_hash being called? It doesn't seem like roar should be involved here, in the processing of an options hash.
Additionally, considering that Rack::Multipart::Parser always calls Tempfile.new with no options, it seems very strange that the error only manifests some of the time.
Stack trace:
The text was updated successfully, but these errors were encountered: