bogeychan / elysia-logger

A plugin for Elysia.js for logging using the pino library
https://npmjs.com/package/@bogeychan/elysia-logger
MIT License
106 stars 5 forks source link

`NotFoundError` doesn't log `onAfterResponse` #19

Open bogeychan opened 1 month ago

bogeychan commented 1 month ago

What versions are running?

{
    "dependencies": {
        "elysia": "1.1.3",
        "@bogeychan/elysia-logger": "0.1.1"
    }
}

What steps can reproduce the bug?

import { Elysia } from "elysia";
import { logger } from "@bogeychan/elysia-logger";

new Elysia()
  .use(logger())
  .get("/", () => "yay")
  .listen(8080);

Open http://localhost:8080/notFound in your browser

What is the expected behavior?

having 2 log entries in console

What do you see instead?

only 1

Additional information

blocked by https://github.com/elysiajs/elysia/issues/713

omarkhatibco commented 1 month ago

I think you need Elysia v1.1

bogeychan commented 1 month ago

@omarkhatibco, I already tried it on elysia 1.1.3 but it doesn't work: https://github.com/bogeychan/elysia-logger/blob/6d9cbe4ddc0767ff0389243d2ab74b97a072ff86/tests/error.test.ts#L68

omarkhatibco commented 1 month ago

@bogeychan my bad, I just noticed you are the author 🙈

I saw you updating the logger 2 days ago and thought to helping you with this issue, did not know it's you

but thank you for the logger

bogeychan commented 1 month ago

all good, I sometimes forget stuff too 😅

There is an issue on elysia's side blocking the progress of this issue (it is mentioned under additional information).

If you need this second 'not found’ log entry, use new Elysia({ aot: false }) as a workaround.