Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pino + NextJs #840

Closed
Manikanta-20 opened this issue May 14, 2020 · 14 comments
Closed

Pino + NextJs #840

Manikanta-20 opened this issue May 14, 2020 · 14 comments

Comments

@Manikanta-20
Copy link

Pino is compatibility with NextJs

@mcollina
Copy link
Member

It should be!

@Manikanta-20
Copy link
Author

i have tried but it was working browser console . i don't know want there it should be nextjs console output.

@mcollina
Copy link
Member

I don't understand. Can you create a repository to reproduce your problem?

@Manikanta-20
Copy link
Author

i will create a respository. give me some time .can you add PR

@Manikanta-20
Copy link
Author

Manikanta-20 commented May 14, 2020

@mcollina download this https://github.com/sai1139/pino-nextjs.git

  1. install packages -> npm dev/yarn dev
    2)in page, click on button .after clicking in browser console log message will get . same message i want in nextjs output console

@Manikanta-20
Copy link
Author

@mcollina any update?

@baterson
Copy link
Contributor

Next.js console shows output during server-side rendering. When you call onSubmit handler it executes in a browser environment, not in the server so Pino is not an issue there.
For example, you can call Pino in the component body and it will log the message during SSR.

export const  Home = () => {
  Pino({}).info({ name: 'John Doe' });
  // ...
}

@mcollina
Copy link
Member

You can follow the discussion in https://github.com/pinojs/pino-nextjs-example/pull/1/files.

@Manikanta-20
Copy link
Author

but every component will not be SSR,In that case.

@Vadorequest
Copy link

Vadorequest commented Jun 1, 2020

Pino completely breaks Next.js

Next.js is isomorphic and runs server side and client side.

TypeError: pino__WEBPACK_IMPORTED_MODULE_0___default(...)(...) is not a function
    at eval (webpack-internal:///./src/utils/logger.ts:5:109)
    at Module../src/utils/logger.ts (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:479:1)
    at __webpack_require__ (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:23:31)
    at eval (webpack-internal:///./src/components/appBootstrap/MultiversalAppBootstrap.tsx:25:72)
    at Module../src/components/appBootstrap/MultiversalAppBootstrap.tsx (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:217:1)
    at __webpack_require__ (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:23:31)
    at eval (webpack-internal:///./src/pages/_app.tsx:23:107)
    at Module../src/pages/_app.tsx (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:312:1)
    at __webpack_require__ (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:23:31)
    at Object.0 (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:502:18)
    at __webpack_require__ (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:23:31)
    at /Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:91:18
    at Object.<anonymous> (/Users/vadorequest/dev/next-right-now/.next/server/static/development/pages/_app.js:94:10)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)


To reproduce:

  1. git clone https://github.com/UnlyEd/next-right-now.git nrn-quick-start - Clones the boilerplate
  2. cd nrn-quick-start && git checkout logger-pino - Working branch
  3. yarn - Installs all deps from package.json
  4. yarn start - Starts the app on http://localhost:8888/

Commenting out the changes in https://github.com/UnlyEd/next-right-now/pull/83/files#diff-9cf0826b88e28a9db80f768366ef2986 "unbreaks" the app.

@mcollina
Copy link
Member

mcollina commented Jun 2, 2020

@Vadorequest check out https://github.com/pinojs/pino-nextjs-example/pull/1/files. As you can see, pino works well with next. I’m not sure what’s the problem of your webpack config.

@Vadorequest
Copy link

This relies on a custom server, which over-complexifies things and is not compatible with the Serverless way of running Next.js.

Also, logs written in the browser are sent to the server, maybe that's the point of the example, but that's weird. And overriding the logger per page (on the server side) is quite redundant.

But indeed it doesn't seem to suffer from a webpack issue.

@kelly-tock
Copy link

This relies on a custom server, which over-complexifies things and is not compatible with the Serverless way of running Next.js.

Also, logs written in the browser are sent to the server, maybe that's the point of the example, but that's weird. And overriding the logger per page (on the server side) is quite redundant.

But indeed it doesn't seem to suffer from a webpack issue.

What do you recommend instead then?

@github-actions
Copy link

github-actions bot commented Feb 4, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants