diff --git a/src/bullet_handler.erl b/src/bullet_handler.erl index c576bda..ee7b484 100644 --- a/src/bullet_handler.erl +++ b/src/bullet_handler.erl @@ -198,8 +198,11 @@ reply_get_mode(eventsource, Data, Req) -> Bin = iolist_to_binary(Data), Event = [[<<"data: ">>, Line, <<"\n">>] || Line <- binary:split(Bin, [<<"\r\n">>, <<"\r">>, <<"\n">>], [global])], - ok = cowboy_req:chunk([Event, <<"\n">>], Req), - {loop, Req}. + case cowboy_req:chunk([Event, <<"\n">>], Req) of + ok -> {loop, Req}; + close -> {ok, Req}; + {error, closed} -> {ok, Req} + end. %% Internal.