Closed vladshcherbin closed 10 months ago
Found the reason from some other issue in codebase:
https://github.com/kysely-org/kysely/blob/0.26.3/src/driver/runtime-driver.ts#L122-L129
It and code below explain why it's logged twice with different duration.
Should it be different though? It's the same one query and its duration should remain the same 🤔
The double logging is clearly a bug. Thanks for letting us know!
I'm guessing the difference in time mostly comes from the actual logging. Writing the first log line to stdout takes that extra 0.5ms.
yep, from driver codebase - when error is thrown, catch
block logs 'error'
log with calculated duration and then finally
block logs 'query'
log with re-calculated duration at that time.
This explains double log, why error
log comes before query
log and why duration differs in current implementation.
as a fix, maybe 'query'
logging can be moved from finally
block to try
block - this would potentially remove double logging
Hi 👋
I'm logging queries using
log
property and when there's an error I can see two logs, first forerror
event, second forquery
event.They have different
queryDurationMillis
. Does it mean the query is executed twice or what's the reasoning for that?Example:
Output:
kysely - 0.26.3 pg - 8.11.3 node - 20.8.0