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

[6.0] Reduce the stacktrace length by 1 line per middleware #29251

Merged

Conversation

florentpoujol
Copy link
Contributor

Hello team

What I suggest here is a minor quality of life improvement during development: it reduces the number of lines in the stacktrace for each middleware from 3 to 2.

On a basic installation of a Laravel app, the stacktrace (as show in the error log) of an exception thrown from a controller action goes from 51 lines to 40.

Currently when an exception is thrown, each middleware that have run takes 3 lines in the stacktrace.
One is for the middleware itself, one for the closure of the base Pipeline class, one for the closure of the Routing Pipeline.

The purpose of the routing Pipeline is to wrap the closure of the base pipeline class in a try/catch block and to send the exception to a method to do proper exception reporting/rendering and to send the response up the middleware stack that already ran.

My change moves the try/catch blocks to the base pipeline class allowing the the Routing Pipeline, to not overwrite the prepareDestination() and carry() methods.
The exception isn't handled in the base pipeline (it just throws it again) but is handled as usual by the routing pipeline.

The effect is one less closure, and one less line in the stacktrace, per middleware, while exceptions are still properly handled and the generated response is passed up the middleware stack.

Thanks for your work !

…ase Pipeline class, but do not handle the Exception there.

This allows the Routing middleware to still properly handle the exception but not wrap closure in more closure, lessening the number of lines in the stacktrace by 1 per middleware.
@taylorotwell taylorotwell merged commit 014f57a into laravel:master Jul 23, 2019
@GrahamCampbell GrahamCampbell changed the title [5.9] Reduce the stacktrace length by 1 line per middleware [6.0] Reduce the stacktrace length by 1 line per middleware Jul 28, 2019
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.

2 participants