newrelic-experimental / newrelic-nextjs-integration

NewRelic Browser and APM agent NextJs integration (front and back-end respectively)
Apache License 2.0
27 stars 22 forks source link

Running the project - front-end not loading on localhost #11

Closed ThinhMaiQuoc closed 1 year ago

ThinhMaiQuoc commented 1 year ago

We are trying to run the project via "npm run dev". (Licenses key provided) image

But the "localhost:3000" never actually load anything out even after a very long time. image

Can you help us with this issue?

matewilk commented 1 year ago

Hey @ThinhMaiQuoc

Thanks for reporting an issue.

I've looked into it and there might be something wrong with your NR configuration. Are you getting anything dumped into newrelic_agent.log file? (it should be automatically created - in the root directory - on NR agent start - when you start the server)

What stops the page from displaying on the front-end side is this condition

It checks whether the New Relic agent collector is connected (when it is connected properly it resolves and moves on)

If you comment this condition out (the entire code block), you should be able to see the page loading as expected (although it might mean there is something wrong with your New Relic configuration/integration)

ThinhMaiQuoc commented 1 year ago

Hi Mat,

Thanks for the response,

By commenting out the front end code block, the app has been able to start. Really appreciated!

And about the newrelic_agent.log file. It seems that my license key appears to be invalid. This is the key that I took directly from the Application settings, so I'm not sure why it's invalid. Is there any other license key that I might have mistaken it with?

Cheers, Thinh Mai.

On Wed, Feb 1, 2023 at 8:22 PM Mat Wilk @.***> wrote:

Hey @ThinhMaiQuoc https://github.com/ThinhMaiQuoc

Thanks for reporting an issue.

I've looked into it and there might be something wrong with your NR configuration. Are you getting anything dumped into newrelic_agent.log file? (it should be automatically created on NR agent start)

What stops the page from displaying on the front-end side is this condition https://github.com/newrelic-experimental/newrelic-nextjs-integration/blob/main/pages/_document.tsx#L24

It checks whether the New Relic agent collector is connected (when it is connected properly it resolves and moves on)

If you comment this condition out (the entire code block), you should be able to see the page loading as expected (although it might mean there is something wrong with your configuration)

— Reply to this email directly, view it on GitHub https://github.com/newrelic-experimental/newrelic-nextjs-integration/issues/11#issuecomment-1412051537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKYG3HDKRE46IIZQZZV6V6DWVJPQ3ANCNFSM6AAAAAAUKTMLBI . You are receiving this because you were mentioned.Message ID: <newrelic-experimental/newrelic-nextjs-integration/issues/11/1412051537@ github.com>

ThinhMaiQuoc commented 1 year ago

{"v":0,"level":30,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:53:58.027Z","msg":"Using New Relic for Node.js. Agent version: 9.8.1; Node version: v16.18.0."} {"v":0,"level":30,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:53:58.251Z","msg":"Using LegacyContextManager"} {"v":0,"level":30,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:53:58.263Z","msg":"Adding destroy hook to clean up unresolved promises.","component":"async_hooks"} {"v":0,"level":30,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:53:58.378Z","msg":"Agent state changed from stopped to starting."} {"v":0,"level":30,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:53:58.396Z","msg":"Not adding native metric sampler.", "component":"sampler","error":{"message":"Cannot find module @.\native-metrics\build\Release\_newrelic_native_metrics-9_0_0-native_metrics-93-win32-x64.node'\nRequire stack:\n- @.\native-metrics\lib\pre-build.js\n- @.\native-metrics\index.js\n- C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\lib\sampler.js\n- C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\lib\agent.js\n- C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\index.js\n- @.\next\index.js\n- internal/preload","stack":"Error: Cannot find module @.\native-metrics\build\Release\_newrelic_native_metrics-9_0_0-native_metrics-93-win32-x64.node'\nRequire stack:\n- @.\native-metrics\lib\pre-build.js\n- @.\native-metrics\index.js\n- C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\lib\sampler.js\n- C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\lib\agent.js\n- C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\index.js\n- @.\next\index.js\n- internal/preload\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)\n at Function.wrappedResolveFilename [as _resolveFilename] (C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\lib\shimmer.js:297:42)\n at Function.Module._load (node:internal/modules/cjs/loader:833:27)\n at Function.wrappedLoad [as _load] (C:\Users\ACER\Desktop\nextjs\newrelic-nextjs-integration\node_modules\newrelic\lib\shimmer.js:313:24)\n at Module.require (node:internal/modules/cjs/loader:1057:19)\n at require (node:internal/modules/cjs/helpers:103:18)\n at Object.load @.\native-metrics\lib\pre-build.js:52:10)\n at Object. @.\native-metrics\index.js:11:26)\n at Module._compile (node:internal/modules/cjs/loader:1155:14)\n at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)"}} {"v":0,"level":30,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:53:58.396Z","msg":"Starting New Relic for Node.js connection process."} {"v":0,"level":30,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:53:58.397Z","msg":"Agent state changed from starting to connecting."} {"v":0,"level":40,"name":"newrelic","hostname":"DESKTOP-P6B26HM","pid":768, "time":"2023-02-02T03:54:00.481Z","msg":"Your license key appears to be invalid. Reattempting connection to New Relic. If the problem persists, please contact @.*** (status code 401)","component": "collector_api"}

Message ID:

<newrelic-experimental/newrelic-nextjs-integration/issues/11/1412051537@ github.com>

matewilk commented 1 year ago

Hi @ThinhMaiQuoc,

If you're instrumenting the app using the newrelic module as it is recommended for Next.js instrumentation for most scenarios please use the Ingest License key. Here you can find a little bit more descriptive explanation.

In the NR UI it will look like this:

Screenshot 2023-02-07 at 13 41 40

You can also create your own Ingest License key in the UI if you wish your app to use a different key.

Hope this helps.

matewilk commented 1 year ago

Hi @ThinhMaiQuoc

Let me know if this solved your issue, if I don't hear from you for a few days I'll close the issue as resolved.