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

Exclude anonymous functions from app #481

Closed
dcramer opened this issue Jul 26, 2017 · 10 comments
Closed

Exclude anonymous functions from app #481

dcramer opened this issue Jul 26, 2017 · 10 comments

Comments

@dcramer
Copy link
Member

dcramer commented Jul 26, 2017

They're not correctly "in app", and if we can't guarantee they are in situations where we've configured an app prefix, let's just exclude them.

Exception: An unhandled exception
#38 app/Http/routes.php(16): {closure}
#37 [Anonymous function](0): call_user_func_array
#36 vendor/laravel/framework/src/Illuminate/Routing/Route.php(155): runCallable
#35 vendor/laravel/framework/src/Illuminate/Routing/Route.php(130): run
#34 vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\{closure}
#33 [Anonymous function](0): call_user_func
#32 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): Illuminate\Pipeline\{closure}
#31 [Anonymous function](0): call_user_func
#30 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): then
#29 vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): runRouteWithinStack
#28 vendor/laravel/framework/src/Illuminate/Routing/Router.php(675): dispatchToRoute
#27 vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): dispatch
#26 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Foundation\Http\{closure}
#25 [Anonymous function](0): call_user_func
#24 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): Illuminate\Pipeline\{closure}
#23 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): handle
#22 [Anonymous function](0): call_user_func_array
#21 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Pipeline\{closure}
#20 vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): handle
#19 [Anonymous function](0): call_user_func_array
#18 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Pipeline\{closure}
#17 vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): handle
#16 [Anonymous function](0): call_user_func_array
#15 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Pipeline\{closure}
#14 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): handle
#13 [Anonymous function](0): call_user_func_array
#12 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Pipeline\{closure}
#11 vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): handle
#10 [Anonymous function](0): call_user_func_array
#9 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Pipeline\{closure}
#8 vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): handle
#7 [Anonymous function](0): call_user_func_array
#6 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Pipeline\{closure}
#5 [Anonymous function](0): call_user_func
#4 vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): then
#3 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): sendRequestThroughRouter
#2 vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): handle
#1 public/index.php(54): require_once
#0 server.php(21): null
@Jean85
Copy link
Collaborator

Jean85 commented Jul 27, 2017

Are we sure that we want to do that? Frameworks like Symfony use a lot of anonymous functions, i.e. for event dispatching or request handling, and hiding those steps could make reading the stack trace a bit difficult.

@dcramer
Copy link
Member Author

dcramer commented Jul 27, 2017

@Jean85 i think this only affects internal PHP functions, but I'm not sure.

@ste93cry
Copy link
Collaborator

Are we sure that in branch 2.x this has not been fixed yet? I refactored a lot of the code that handles the stacktraces, and if I remember correctly the anonymous functions should have the appropriate caller file path

@Jean85
Copy link
Collaborator

Jean85 commented Jul 27, 2017

@ste93cry if you refactored this, it's great!

@dcramer actually I see as anonymous functions any closure or inline function, so a lot of framework code can be considered like that.

@dcramer
Copy link
Member Author

dcramer commented Jul 27, 2017

I'm not sure if it's changed in 2.x but as I've said before, while the rewrite is great, it doesn't mean we're abandoning things until it's done.

@dcramer
Copy link
Member Author

dcramer commented Jul 27, 2017

@Jean85 i think the thing we need to confirm is, do the closures that are defined in Foo.php show up as being defined there? The main issue is the ones that are without file location.

Per @stayallive's suggestion in the PR, I do think we can improve by doing reflection when possible, and that might ensure that "all app code has a filename".

@Jean85
Copy link
Collaborator

Jean85 commented Jul 31, 2017

This is an example from my setup with Symfony 3:

sentry_anon_functions

Obviously, the first row above that is my controller. Is this enough?

@dcramer
Copy link
Member Author

dcramer commented Jul 31, 2017

mmm yeah we will want to confirm if we do reflection if we still get the controller as the filename, since the main goal is to avoid breaking apart the stacktrace repeatedly (which is what happens in laravel right now)

@Jean85
Copy link
Collaborator

Jean85 commented Jul 31, 2017

I do not have a Laravel app to do the same test... someone else?

@stayallive
Copy link
Collaborator

Yeah I didn't test the code yet but will try it out to see if it helps on Laravel.

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

4 participants