Git Product home page Git Product logo

Comments (12)

kyegupov avatar kyegupov commented on April 28, 2024 2

CallLogger currently does not work as it should: #50

On top of that, swallowing exceptions silently by default is a very bad practice, resulting in an incredibly hostile learning curve.

Perhaps tutorial-mode setups like embeddedJettyServer(routing = ...).start() should have it baked in by default, with logging to stdout/stderr preconfigured?

from ktor.

orangy avatar orangy commented on April 28, 2024 1

Just a matter of notice, we have a test for this case (throwing inside respondWrite), but it didn't fail because in test environment it was not "asynchronous enough". Need proper integration test…

from ktor.

orangy avatar orangy commented on April 28, 2024 1

I verified this case in our new coroutine-based implementation and everything is good (given CallLogging is installed)

from ktor.

cy6erGn0m avatar cy6erGn0m commented on April 28, 2024

You can install CallLogger feature to see exceptions

class Blocking(environment: ApplicationEnvironment) : Application(environment) {
    init {
        install(CallLogging)

        routing {

from ktor.

orangy avatar orangy commented on April 28, 2024

It's not that we swallow exceptions by default, as you picture it. Highly async code is hard to make bullet-proof, but we are moving there. Missing a catch-and-marshall in one place can easily look like swallowing, but it's actually may be accidentally ignored in CompletableFuture callback or something.

from ktor.

spand avatar spand commented on April 28, 2024

I think my confusion about this is now a little bit clearer. I did not know we had calllogging in our setup so I thought it was the default behaviour. In any case exceptions are actually being swallowed here. If you add install(CallLogging) it will only print one stack trace to the console. The first in route /exception is not being reported.

from ktor.

orangy avatar orangy commented on April 28, 2024

@spand I've reproduced the issue, but I see it not reported for exception2. Exception for exception route is reported if CallLogging is installed.

from ktor.

orangy avatar orangy commented on April 28, 2024

So indeed, it's not a swallowed exception. It's a double-exception error. It hits CallLogging interceptor with correct exception on a failing path. But then CallLogging tries to get method from an HttpRequest to show which request failed, and fails to get it, because request is already closed.

Thanks for noticing, we will fix it.

from ktor.

spand avatar spand commented on April 28, 2024

Oh, my mistake again. Glad to be of service in any case ;-)

from ktor.

kyegupov avatar kyegupov commented on April 28, 2024

I have a feeling the async core of ktor is going to be a nightmare to maintain, so it's unlikely for ktor to be production-ready anytime soon :( shame, since Kara development appears to be mostly dormant and Wasabi is also quite unstable (Gradle builds, ugh).

from ktor.

spand avatar spand commented on April 28, 2024

Any progress on this ?

from ktor.

orangy avatar orangy commented on April 28, 2024

Debug note:
This is caused by https://github.com/Kotlin/ktor/blob/7f72bd3fcf7d53d289a3252dcac39a5300db413a/ktor-hosts/ktor-hosts-common/src/org/jetbrains/ktor/host/BaseApplicationCall.kt#L115-L115

closeAtEnd in sendAsyncChannel installs failure handler to properly close a call in case of failure or success, and it executes before CallLogging have a chance to report an exception. Then call.request.logInfo() fails because underlying request was already cleaned up.

from ktor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.