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

Next.js app fails during build with Error: DAPR_SIDECAR_COULD_NOT_BE_STARTED #566

Closed
xendren opened this issue Jan 19, 2024 · 3 comments
Closed

Comments

@xendren
Copy link

xendren commented Jan 19, 2024

Ask your question here

We are using Next.js for building our react application. We have followed the JavaScript SDK examples for fetching secrets using the Dapr SDK. Everything is working fine in standalone mode, but we are getting the error below when running next build. It appears to be awaiting the sidecar to startup during the build for some reason. I'll post the question on Next.js project as well.

Any help would be appreciated.

"Error: DAPR_SIDECAR_COULD_NOT_BE_STARTED"

@shubham1172
Copy link
Member

Hi @xendren, if it's a front-end application then the SDK won't work. It needs a Node runtime.

Also

It appears to be awaiting the sidecar to startup during the build for some reason

Could you share what commands you're using to start the app (with SDK) and sidecar, and share a minimum reproducible example with logs? Also curious to know, what is this next.js project?

@xendren
Copy link
Author

xendren commented Jan 22, 2024

Hi @xendren, if it's a front-end application then the SDK won't work. It needs a Node runtime.

Also

It appears to be awaiting the sidecar to startup during the build for some reason

Could you share what commands you're using to start the app (with SDK) and sidecar, and share a minimum reproducible example with logs? Also curious to know, what is this next.js project?

This is a react app using Next.js framework. This error is occurring during the "next build" command to prepare for deployment, so this isn't even at runtime. Next.js appears to be executing code during the build optimization process.

I have tried installing the Dapr CLI and runtime during the build, but it gets the same error. Oddly, it will only pass the build process if the sidecar is actually running. I'm guessing the Next.js optimization process is doing something it shouldn't. I posted this question in hopes that someone might have some ideas. Our next thing to try is to switch to making the sidecar calls without using the dapr js-SDK, but I was hoping to avoid that if possible.

@xendren
Copy link
Author

xendren commented Jan 25, 2024

For anyone else that encounters this problem, we were able to solve it by moving the Dapr client logic to the instrumentation.js source and enabling the instrumentation feature in the Next.js configuration. This feature is used to execute server side code once at startup. Here is a link to the Next.js docs on instrumentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants