Skip to content

chore: Updated app router example to wait for agent to connect and require dotenv in config to load .env for new relic config#376

Merged
bizob2828 merged 1 commit into
mainfrom
fix-next-aopp
Jun 9, 2026
Merged

chore: Updated app router example to wait for agent to connect and require dotenv in config to load .env for new relic config#376
bizob2828 merged 1 commit into
mainfrom
fix-next-aopp

Conversation

@bizob2828

Copy link
Copy Markdown
Member

In #374 the app was refactored to work with Next 16 and show how to use turbopack. During that refactor, injecting the browser agent broke. This PR resolves that by waiting for the agent to be connected before getting the browser agent header. Also combines dotnev in config as next.js 16 messes with NODE_OPTIONS and combines duplicate cli args. to --require dotenv/config and --require newrelic would be --require dotenv/config newrelic which no longer works, yay Next.js!

…quire `dotenv` in config to load `.env` for new relic config

@jsumners-nr jsumners-nr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but maybe we should wait on started instead?

Comment on lines +21 to +24
if (newrelic.agent.collector.isConnected() === false) {
await new Promise((resolve) => {
newrelic.agent.on('connected', resolve)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connected is enough as we have what we need from collector to provide the browser agent js

@bizob2828 bizob2828 merged commit 98f0fa2 into main Jun 9, 2026
8 checks passed
@bizob2828 bizob2828 deleted the fix-next-aopp branch June 9, 2026 13:37
@github-project-automation github-project-automation Bot moved this from Needs PR Review to Done: Issues recently completed in Node.js Engineering Board Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done: Issues recently completed

Development

Successfully merging this pull request may close these issues.

3 participants