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

Check for :raise_errors config before calling it #156

Merged
merged 1 commit into from Sep 16, 2016

Conversation

jeffkreeftmeijer
Copy link
Member

Rack middleware doesn't usually include a #settings method, so we can't
rely on it existing in Appsignal::SinatraBaseInstrumentation.

Rack middleware doesn't usually include a #settings method, so we can't
rely on it existing in Appsignal::SinatraBaseInstrumentation.
@tombruijn
Copy link
Member

This happens when another middleware is loaded before appsignal's middleware, right?

In this scenario you would lose the setting raise_errors if it's set on the application, because you're asking the middleware.


But don't middleware wrap each other? So can we call up, find the original application and ask it its settings?

some_app = @app
while !some_app.is_a? Sinatra::Base
  some_app = some_app.instance_variable_get(:@app)
end

but that's of course pretty terrible and brittle. We can't ask ::Sinatra::Application.settings either, because that only works for non-modular apps.

So... ¯_(ツ)_/¯ ?


Your solution will not crash the application anymore 👍 , but does seem to break the config.

@jeffkreeftmeijer
Copy link
Member Author

Agreed. As middleware is stacked, we should be able to call the "main" app for its config. However, the while loop looks a little too scary for me, do I think we should take a bit more time to get to a solution that's more stable.

Without this patch, every Sinatra app with middleware that doesn't have a #settings method won't start. With this patch, it will, but it can lose the config in the middleware. I propose we create a new issue to look into it some more, but merging this and pushing a gem update so apps like this can at least start. wdyt? :)

@tombruijn
Copy link
Member

Applying this patch 👍
Creating a new issue 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants