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

The service is no longer running immediately logged when npm run dev #18

Closed
zolrath opened this issue Mar 16, 2022 · 11 comments
Closed

Comments

@zolrath
Copy link

zolrath commented Mar 16, 2022

What version of Remix are you using?

1.3.1

Steps to Reproduce

  1. Create a new project using the blues stack.
  2. cd into the directory
  3. npm run docker
  4. npm run setup
  5. npm run dev

Expected Behavior

pm2 should launch the application and supporting watches with no errors displayed.

Actual Behavior

Eventually all applications succeed to launch, but Server fails the first time it is run with Error: The service is no longer running.

After pm2 restarts Server it successfully runs on the second launch.

❯ npm run dev

> dev
> pm2-dev ./other/pm2.config.js

===============================================================================
--- PM2 development mode ------------------------------------------------------
Apps started         : Server,Server Build,Remix,Tailwind
Processes started    : 4
Watch and Restart    : Enabled
Ignored folder       : node_modules
===============================================================================
Server-0  | Debugger listening on ws://127.0.0.1:9229/9752a099-019e-4ec1-9379-ee5c5959b3f7
Server-0  | For help, see: https://nodejs.org/en/docs/inspector
Server Build-1  | > build:server
Server Build-1  | > esbuild --platform=node --format=cjs ./server.ts --outdir=build "--watch"
Server-0        | 🔶 Mock server running
Server Build-1  | [watch] build finished, watching for changes...
Tailwind-3      | > generate:css
Tailwind-3      | > tailwindcss -o ./app/styles/tailwind.css "--watch"
Server-0        | /Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:658
Server-0        |       return callback("The service is no longer running", null);
Server-0        |              ^
Server-0        | Error: The service is no longer running
Server-0        |     at /Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:1375:29
Server-0        |     at sendRequest (/Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:658:14)
Server-0        |     at start (/Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:1373:9)
Server-0        |     at Object.transform2 [as transform] (/Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:1430:5)
Server-0        |     at /Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:2099:55
Server-0        |     at new Promise (<anonymous>)
Server-0        |     at Object.transform (/Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:2099:14)
Server-0        |     at /Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:2253:65
Server-0        |     at MessagePort.<anonymous> (/Users/furd/Code/blues-test/node_modules/esbuild/lib/main.js:2269:7)
Server-0        |     at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:647:20)
Server-0        | Debugger listening on ws://127.0.0.1:9229/5e82594d-c4cf-41d7-887d-83f1c2128eb1
Server-0        | For help, see: https://nodejs.org/en/docs/inspector
Remix-2         | Watching Remix app in development mode...
Server-0        | 🔶 Mock server running
Tailwind-3      | Rebuilding...
Remix-2         | 💿 Built in 436ms
Tailwind-3      | Done in 273ms.
Server-0        | 🔌 setting up prisma client to localhost:5432
Server-0        | ✅ app ready: http://localhost:3000
@kentcdodds
Copy link
Member

Odd! Does this reproduce successfully every time you start? I'm kinda thinking this was a fluke that's probably not easy/worth investigating 😬

@zolrath
Copy link
Author

zolrath commented Mar 16, 2022

It happens every time I run it! I've tried about 30 times and haven't had a single run where it didn't have the same behavior.

❯ node -v
v16.14.0

❯ npm -v
8.3.1

@kentcdodds
Copy link
Member

Dang! It looks like the error is coming from esbuild. Maybe related to our use of esbuild-register in the mocks. If you comment out this line

"--require ./mocks",
does it have the same problem still?

@zolrath
Copy link
Author

zolrath commented Mar 17, 2022

With that line commented the large error message is gone.
We've got one rebuild triggering a restart of the server during boot-up, not sure if that might be part of the cause of the error message with mocks enabled.

❯ npm run dev

> dev
> pm2-dev ./other/pm2.config.js

===============================================================================
--- PM2 development mode ------------------------------------------------------
Apps started         : Server,Server Build,Remix,Tailwind
Processes started    : 4
Watch and Restart    : Enabled
Ignored folder       : node_modules
===============================================================================
Server-0  | Debugger listening on ws://127.0.0.1:9229/0981dbea-080a-43a7-834a-ac031b79332a
Server-0  | For help, see: https://nodejs.org/en/docs/inspector
Server Build-1  | > build:server
Server Build-1  | > esbuild --platform=node --format=cjs ./server.ts --outdir=build "--watch"
Server Build-1  | [watch] build finished, watching for changes...
Tailwind-3      | > generate:css
Tailwind-3      | > tailwindcss -o ./app/styles/tailwind.css "--watch"
Server-0        | 🔌 setting up prisma client to localhost:5432
Server-0        | ✅ app ready: http://localhost:3000
Remix-2         | Watching Remix app in development mode...
Server-0        | Debugger listening on ws://127.0.0.1:9229/640f9795-0f0a-46ea-8c75-967e558b05d7
Server-0        | For help, see: https://nodejs.org/en/docs/inspector
Tailwind-3      | Rebuilding...
Remix-2         | 💿 Built in 337ms
Server-0        | 🔌 setting up prisma client to localhost:5432
Server-0        | ✅ app ready: http://localhost:3000
Tailwind-3      | Done in 237ms.

@kentcdodds
Copy link
Member

I've seen someone else report this same issue. I'm still unable to reproduce this personally. Maybe we should come up with a different approach for what we're doing. I like using esbuild-register, but we could use ts-node instead...

@antoninbeaufort
Copy link

antoninbeaufort commented Mar 19, 2022

I can confirm the existence of the bug, I have it with the original blues stack without any modification on Windows 11 WSL 2 (Ubuntu) with the following versions:

  • Node: v16.14.1
  • NPM: 8.5.0

For me, this error does not occur at the first launch after booting the PC.

@zolrath
Copy link
Author

zolrath commented Mar 19, 2022

If I comment out the "Server Build" aspect of pm2 we don't cause "Server" to be restarted halfway through boot-up, removing the error.

❯ npm run dev

> dev
> pm2-dev ./other/pm2.config.js

===============================================================================
--- PM2 development mode ------------------------------------------------------
Apps started         : Server,Remix,Tailwind
Processes started    : 3
Watch and Restart    : Enabled
Ignored folder       : node_modules
===============================================================================
Server-0  | Debugger listening on ws://127.0.0.1:9229/e862d854-3acb-4940-9022-9bc16b48eb45
Server-0  | For help, see: https://nodejs.org/en/docs/inspector
Server-0  | 🔶 Mock server running
Tailwind-2  | > generate:css
Tailwind-2  | > tailwindcss -o ./app/styles/tailwind.css "--watch"
Remix-1     | Watching Remix app in development mode...
Server-0    | 🔌 setting up prisma client to localhost:5432
Server-0    | ✅ app ready: http://localhost:3000
Tailwind-2  | Rebuilding...
Remix-1     | 💿 Built in 364ms
Tailwind-2  | Done in 227ms.

I don't see any way in pm2 for an app to be dependent on another app, would be great to have "Server" wait for "Server Build" to be complete before starting.

@Zloka
Copy link

Zloka commented Mar 21, 2022

Dang! It looks like the error is coming from esbuild. Maybe related to our use of esbuild-register in the mocks. If you comment out this line

"--require ./mocks",

does it have the same problem still?

I noticed the same issue in a fresh project. Commenting out this line seems to remove the problem. Is there some other information I could provide to help with debugging? 🙂

@RealMattOwen
Copy link

Same here, happy to help just unsure how 😄

@kentcdodds
Copy link
Member

Switched to ts-node and now it works great :)

@kubeworkz
Copy link

kubeworkz commented Feb 16, 2023

Same issue here. I have a pipeline setup in ArgoCD to build my Remix app. Argo says everything was successful, then after about 30 seconds of watching the log I get:

Done in 86302ms.
[Feb 16 2023 18:08:27 GMT-0500] remix-saas-kit-devtron-demo-6f85648fb9-kbt8n: [1] The service was stopped
[Feb 16 2023 18:08:27 GMT-0500] remix-saas-kit-devtron-demo-6f85648fb9-kbt8n: [1] 💿 Built in 5m 28.5s
[Feb 16 2023 18:08:27 GMT-0500] remix-saas-kit-devtron-demo-6f85648fb9-kbt8n: [1] Error: The service is no longer running
[Feb 16 2023 18:08:27 GMT-0500] remix-saas-kit-devtron-demo-6f85648fb9-kbt8n: [1]     at sendResponse (/app/node_modules/@remix-run/dev/node_modules/esbuild/lib/main.js:677:13)
[Feb 16 2023 18:08:27 GMT-0500] remix-saas-kit-devtron-demo-6f85648fb9-kbt8n: [1]     at handleRequest (/app/node_modules/@remix-run/dev/node_modules/esbuild/lib/main.js:740:7)
[Feb 16 2023 18:08:27 GMT-0500] remix-saas-kit-devtron-demo-6f85648fb9-kbt8n: [1]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[Feb 16 2023 18:08:28 GMT-0500] remix-saas-kit-devtron-demo-6f85648fb9-kbt8n: [1] cross-env NODE_ENV=development remix dev exited with code 1

I run node 16.x. I also load pm2 in my Github Action but nothing fancy. You mention ts-node - where do I use that? btw: This happens in dev and prod mode.
Cheers, Dave

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

6 participants