rafiki icon indicating copy to clipboard operation
rafiki copied to clipboard

Fix `frontend` issue when running with NODE_ENV=development

Open mkurapov opened this issue 1 year ago • 2 comments

Context

Spinning up Rafiki via helm charts results in an error in the frontend package:

Error: Dev server origin not set                                                                                                                                                                                                                         
    at Object.broadcastDevReady (/home/rafiki/node_modules/.pnpm/@[email protected][email protected]/node_modules/@remix-run/server-runtime/dist/dev.js:17:22)                                                                              
    at Server.onListen (/home/rafiki/node_modules/.pnpm/@[email protected][email protected]/node_modules/@remix-run/serve/dist/cli.js:123:17)                                                                                                        
    at Object.onceWrapper (node:events:631:28)                                                                                                                                                                                                           
    at Server.emit (node:events:529:35)                                                                                                                                                                                                                  
    at emitListeningNT (node:net:1851:10)                                                                                                                                                                                                                
    at processTicksAndRejections (node:internal/process/task_queues:81:21) 

This is a result of:

  • https://github.com/remix-run/remix/discussions/7338

after we upgraded to remix v2:

  • https://github.com/interledger/rafiki/pull/2349

The issue/error message was fixed after setting NODE_ENV=production.

It is likely that when the helm charts are setting the NODE_ENV=development when building the frontend package, this causes a _dev_ build of remix to happen, and during `remix-serve` for running the app, the app complains because it expected a dev server.

(Potentially) useful resources:

  • https://remix.run/docs/en/main/other-api/dev#remix-build
  • https://remix.run/docs/en/main/start/v2#remix-serve
  • https://remix.run/docs/en/main/guides/manual-mode#remix-serve

Todos

  • [ ] Fix the error message when running the frontend package in a deployed environment (via helm)

mkurapov avatar Mar 20 '24 13:03 mkurapov

Just to follow up on the possibility of continuing to use development, looking at the remix-serve cli, I do not see any scenario where we can use NODE_ENV=development and not run some sort of dev server. https://github.com/remix-run/remix/blob/9661da31e589fc4eda042ab2f6f963cefba380ed/packages/remix-serve/cli.ts I think this works this way strictly for remix-dev since that uses remix-serve as the app server according to the docs.

If you are running remix dev without the -c flag, then you are implicitly using remix-serve as your app server.

https://remix.run/docs/en/main/guides/manual-mode#remix-serve

Taking a step back, I wonder what NODE_ENV we should be using in our helm charts in general. If used in some staging environment I imagine we would want it to be as close to production as possible, no?

BlairCurrey avatar Mar 20 '24 13:03 BlairCurrey

I also added nodeEnv in helm charts so that users can specify nodeEnv in values.yaml file on helm install / upgrade. This is also consistent with other Rafiki packages (auth and backend)

https://github.com/interledger/helm-charts/pull/27

golobitch avatar Mar 27 '24 23:03 golobitch

Resolved with env var in helm repo

BlairCurrey avatar May 14 '24 14:05 BlairCurrey