vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.37k stars 27.02k forks source link

PINO logger causing cannot find module '/ui/.next/server/app/api/order/lib/worker.js' #54289

Closed u1x30 closed 1 year ago

u1x30 commented 1 year ago

Verify canary release

Provide environment information

Environment:

    Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP PREEMPT_DYNAMIC Sun Jun 25 16:39:03 CEST 2023
    Binaries:
      Node: 20.5.0
      npm: 9.3.1
      Yarn: 1.22.19
      pnpm: 8.6.7
    Relevant Packages:
      next: 13.4.19
      eslint-config-next: 13.4.10
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

Thank you for your support.

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

Do not have replay bug

To Reproduce

Make a PINO logger call from any app/api endpoint.

Describe the Bug

Nextjs13 app/api endpoints error when using the pino logger:

node:internal/event_target:1037 process.nextTick(() => { throw err; }); ^ Waiting for the debugger to disconnect... Error: Cannot find module '/ui/.next/server/app/api/order/lib/worker.js'

error node_modules/thread-stream/index.js (229:18) @ ThreadStream.write error uncaughtException: Error: the worker has exited at ThreadStream.write (webpack-internal:///(sc_server)/./node_modules/thread-stream/index.js:193:25) at Pino.write (webpack-internal:///(sc_server)/./node_modules/pino/lib/proto.js:162:12) at Pino.LOG [as debug] (webpack-internal:///(sc_server)/./node_modules/pino/lib/tools.js:47:27 Endpoint does not call logger directly and calls service that uses the pino logger.

Pino works fine with page/api endpoints.

NextJS recommends Pino:

https://nextjs.org/docs/pages/building-your-application/deploying/production-checklist#logging

https://vercel.com/templates/next.js/pino-logging

PINO logger works fine with pages/api endpoints which is reason why did not upgrade endpoints to the app/api directory.

Are any plans for Pino app/api support or work arounds to get it working? Should we abandon the recommendation and go with other logger for NextJS 13 app/api?

This issue is preventing us from upgrading our API enpoints to the app/api. At very least, please provide us details on what logger is supported.

Expected Behavior

Pino logs statement without error.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

balazsorban44 commented 1 year ago

Mind adding Pino to experimental.serverComponentsExternalPackages to see if it helps?

Context: https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages

If this does not help, please open a new issue with a linked reproduction, so we can investigate. The example you linked to uses pages but you are mentioning that it does not work in the App Router, so it's not an actual reproduction.

github-actions[bot] commented 1 year ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.