Plack::...ackTrace(3)

πŸ’– Plack::...ackTrace(3) πŸ’–

okay bestie, welcome to Plack::...ackTrace(3) β€” that's the User Contributed Perl Documentation edition, and no, the title really is chopped like that, it's giving "we ran out of room in the header" energy πŸ™ˆ. Anyway. Sit down, grab a strawberry πŸ“, and lemme tell you about this little middleware that goes feral when your app dies.


✨ NAME ✨

Plack::Middleware::StackTrace β€” bestie it displays a stack trace when your app dies. that's the whole job. tragic but iconic πŸ’…


🌈 SYNOPSIS 🌈

enable "StackTrace";

one line. that's it. she's low maintenance like that 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•: this middleware uses $SIG{__DIE__} to intercept every single exception (run-time errors) happening in your application β€” and I mean every one, even the ones that get caught 😭. For each exception it builds a detailed stack trace. obsessive? yes. useful? also yes.

If the application aborts by throwing an exception, it will be caught and matched against the saved stack traces. If a match is found, it gets displayed as a nice stack trace screen β€” gorgeous, stunning, frame it. If not? then the exception gets reported without a stack trace. no match, no glamour πŸ’€.

The stack trace is also stored in the environment as plaintext and HTML under the key plack.stacktrace.text and plack.stacktrace.html respectively, so that middleware further up the stack can reference it. sharing is caring, queens πŸ‘‘

This middleware is enabled by default when you run plackup in the default development mode. not me being on by default ✨

You're recommended to use this middleware during development, and to use Plack::Middleware::HTTPExceptions in deployment mode as a replacement β€” so that all the exceptions thrown from your application still get caught and rendered as a 500 error response, rather than crashing the web server. crashing the web server is NOT the vibe, bestie 🚨
Catching errors in streaming response is not supported. that's it, that's the limit, don't come for her 🌸

πŸ’œ Stack Trace Module πŸ’œ

The Devel::StackTrace::WithLexicals module will be used to capture the stack trace if the installed version is 0.08 or later. Otherwise Devel::StackTrace is used. loyalty test, but make it version numbers πŸŽ€

⚑ Performance ⚑

Gathering the information for a stack trace via Devel::StackTrace is slow, and Devel::StackTrace::WithLexicals is significantly slower still. incredibly slow. aggressively slow. πŸ’€

This is not usually a concern in development, and when exceptions are rare. However β€” and this is the part you need to hear β€” your application may include code that's throwing and catching exceptions that you're not aware of. Such code will run significantly slower with this module. so like, know before you go, iykyk 🧚


πŸŽ€ CONFIGURATION πŸŽ€

  • force
enable "StackTrace", force => 1;

Force display the stack trace when an error occurs within your application and the response code from your application is 500. Defaults to off.

The use case of this option: when your framework catches all the exceptions in the main handler and returns all failures in your code as a normal 500 PSGI error response. In such cases, this middleware would never have a chance to display errors, because it can't tell if it's an application error or just random eval in your code. πŸ™ˆ This option enforces the middleware to display a stack trace even if it's not the direct error thrown by the application. she said "I'm showing it anyway" πŸ’…

  • no_print_errors
enable "StackTrace", no_print_errors => 1;

Skips printing the text stacktrace to console (psgi.errors). Defaults to 0, which means the text version of the stack trace error is printed to the errors handle, which usually is a standard error. quiet mode: activated 🀫


πŸ‘‘ AUTHOR πŸ‘‘

  • Tokuhiro Matsuno
  • Tatsuhiko Miyagawa

legends. periodt. 🫢


🌸 SEE ALSO 🌸

  • Devel::StackTrace::AsHTML
  • Plack::Middleware
  • Plack::Middleware::HTTPExceptions

and that's the whole page, bestie!! πŸ’– this was perl v5.42.3 flavored, dated 2026-10-18, and brought to you by the Plack::...ackTrace(3) girlies. slay, hydrate, and go read your stack traces responsibly βœ¨πŸ’…πŸŒˆ

πŸ“¦ where this page comes from