Comments (12)
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.
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.
I verified this case in our new coroutine-based implementation and everything is good (given CallLogging is installed)
from ktor.
You can install CallLogger
feature to see exceptions
class Blocking(environment: ApplicationEnvironment) : Application(environment) {
init {
install(CallLogging)
routing {
from ktor.
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.
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.
@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.
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.
Oh, my mistake again. Glad to be of service in any case ;-)
from ktor.
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.
Any progress on this ?
from ktor.
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)
- Ktor/Netty hang up while Ktor/Jetty is fine HOT 2
- `Route.param()` is not work
- Random NPEs in CIOEngine HOT 1
- Invalid hex byte exception when decoding invalid query string HOT 1
- parameters in the builder is not configurable HOT 1
- Ktor works fine in Intellij but not on command line HOT 1
- Project 'tomcat-war' not found in root project HOT 5
- I have the same exception in version 1.6.2. HOT 2
- DefaultRequest Plugin - InvalidMutabilityException When Changing Anything Except Protocol - 2.0.0-beta-1 on iOS HOT 1
- Ktor server :: not working when application in background Android API 21 (5.0+) HOT 2
- Old version of jwt HOT 1
- Jetty Engine - Overwriting custom handlers HOT 1
- Could not find io.ktor:ktor-gson:2.0.2 HOT 2
- Dependency Dashboard
- Can't pass SSL handshake on KMM project
- CIO Request Timed Out on large files HOT 4
- question: why to set full url in packet instead of just query for proxy? HOT 4
- ReaderJob & WriterJob leak in TLS socket and prevent context from completion HOT 3
- Bearer auth token refresh hangs after prior refresh threw an exception HOT 1
- renderSetCookieHeader shouldn't ignore maxAge = 0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ktor.