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

Puma does not handle SyntaxError properly #1027

Closed
rosenfeld opened this issue Jul 22, 2016 · 5 comments
Closed

Puma does not handle SyntaxError properly #1027

rosenfeld opened this issue Jul 22, 2016 · 5 comments

Comments

@rosenfeld
Copy link

Please take a look at the responses for these two Rack apps. It seems Puma doesn't handle SyntaxError properly as it does for regular errors:

# config.ru for regular error
run ->(env) { raise 'Error' }

# config.ru for SyntaxError
run ->(env) { require_relative 'abc' }

# abc.rb
class # invalid syntax

Would it be possible for Puma to fix the HTTP response in the latter case?

@jeremyevans
Copy link
Contributor

Roda rescues both StandardError and ScriptError in its error handling plugin, it might be a good idea for Puma to do something similar.

@evanphx
Copy link
Member

evanphx commented Jul 24, 2016

Fixed! Thanks for pointing it out, I agree (and thusly followed suit with the code change) that it should catch more exceptions here.

@rosenfeld
Copy link
Author

Thanks! Any reasons for not simply rescue Exception?

@evanphx
Copy link
Member

evanphx commented Jul 24, 2016

I've done that before though I'm generally against it because it also catches NoMemoryError, for which there is really no recovery and the process needs to just die.

Though, ThreadPool does rescue Exception so, actually, I should probably change it to Exception.

@evanphx evanphx reopened this Jul 24, 2016
@rosenfeld
Copy link
Author

I see, it makes sense. Even when no memory is available I believe it's a valid attempt trying to better handle the response. Thanks.

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

No branches or pull requests

3 participants