[dancer-users] BUG? client disconnect not handled in delayed route

Paul Clements paul.clements at us.sios.com
Sat Jan 23 16:30:37 EST 2021


Hi,

I've been having trouble getting the server (tried the default PSGI
one and Starman) to notice when a client disconnects from a delayed
route handler. Long story short, I was able to finally debug this down
to the content subroutine in DSL.pm. With the change below, I'm now
able to detect and properly handle a disconnect (in my case, I'm just
hitting ^C on a client curl session).

My question is: Does this seem like a proper fix (should I prepare a
PR), or is there a better way to handle this?

- Paul

---

$ diff -pu git/Dancer2/lib/Dancer2/Core/DSL.pm .
--- git/Dancer2/lib/Dancer2/Core/DSL.pm 2020-12-31 11:21:47.490454726 -0500
+++ ./DSL.pm    2021-01-23 11:07:47.464438846 -0500
@@ -328,7 +328,8 @@ sub content {
     }

     eval {
-        $Dancer2::Core::Route::WRITER->write(@_);
+        my $res = $Dancer2::Core::Route::WRITER->write(@_);
+        die "Write Error\n" if (!defined($res));
         1;
     } or do {
         my $error = $@ || 'Zombie Error';


More information about the dancer-users mailing list