Hey does anyone know why whenever an invalid route...
# ktor
t
Hey does anyone know why whenever an invalid route is passed to the API StatusPages sends the request back twice? Checking if it was sent/committed doesn't resolve the issue.
I fixed it by adding a wild card route at the top of my
routing {}
scope and simply throwing a not found exception. When an invalid route is used it automatically returns HTTP 404 then my
statuses
block in
StatusPages
also picks it up which sends back two HTTP requests in the pipeline (to my understanding)
Copy code
route("{...}") {
            handle { throw ResourceNotFoundException() }
        }
a
Can you share the complete code snippet?
t
For what's causing the double call respond?
a
I cannot reproduce your problem with the following code:
Copy code
embeddedServer(Netty, port = 8082) {
    install(StatusPages) {
        status(HttpStatusCode.NotFound) { call, _ ->
            call.respondText { "NOT FOUND" }
        }
    }

    routing {

    }
}.start(true)
And by making a
<http://localhost:8082/test>
request.
t
Do you have call monitoring set up? When I’m available I’ll set up a repository
a
It seems to be a buggy behavior. I've created an issue to address it.
t
Gotcha, appreciate it
I'm not exactly sure if it's actually sending the request back twice or just logging it twice. I've had instances where the response times were different which makes me believe two requests are being sent back
a
if it is listener/subscriber based there is a bug related to dev mode