Skip to content

Non-fatal exception raised during automatic code reload #5

Description

@YellowApple

During the request immediately following a source code change:

08:21:18.469 [info]  GET /

08:21:18.470 [error] #PID<0.1025.0> running Foo.Router terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
    ** (Plug.Conn.AlreadySentError) the response was already sent
        (plug) lib/plug/conn.ex:864: Plug.Conn.register_before_send/2
        (splor) lib/foo/router.ex:1: Foo.Router.do_call/2
        (splor) lib/plug/debugger.ex:93: Foo.Router.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

08:21:18.499 [info]  GET /

08:21:18.499 [info]  Sent 200 in 26µs

Router resembles the following:

defmodule Foo.Router do
  use Sugar.Router
  plug Sugar.Plugs.HotCodeReload
  plug Plug.Logger  # Not necessary to reproduce, but logs the requests

  # ...

  get "/", Foo.Controllers.Main, :index
end

Controller resembles the following:

defmodule Foo.Controllers.Main do
  use Sugar.Controller

  def index(conn, _) do
    conn |> render  # or something; this doesn't matter
  end
end

My hypothesis is that the exception is coming from a stale connection (namely, the one that initiated the code reload). Totally harmless, but would be worth checking out nonetheless if it's a sign of some optimization issue (it's possible that we might be able to shave a bit more off that rather slow 26-microsecond response time ;) ).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions