I can't deploy my remixjs app due to health check issue

+] Building 9.8s (21/21) FINISHED
=> [internal] load remote build context 0.0s
=> copy /context / 0.1s
=> [internal] load metadata for Docker 0.7s
=> [base 1/2] FROM Docker 0.0s
=> CACHED [base 2/2] RUN apt-get update && apt-get install -y openssl 0.0s
=> CACHED [build 1/6] WORKDIR /myapp 0.0s
=> CACHED [deps 2/3] ADD package.json package-lock.json .npmrc ./ 0.0s
=> CACHED [deps 3/3] RUN npm install --production=false 0.0s
=> CACHED [build 2/6] COPY --from=deps /myapp/node_modules /myapp/node_modules 0.0s
=> CACHED [build 3/6] ADD prisma . 0.0s
=> CACHED [build 4/6] RUN npx prisma generate 0.0s
=> [build 5/6] ADD . . 0.1s
=> [build 6/6] RUN npm run build 6.4s
=> CACHED [production-deps 3/4] ADD package.json package-lock.json .npmrc ./ 0.0s
=> CACHED [production-deps 4/4] RUN npm prune --production 0.0s
=> CACHED [stage-4 2/6] COPY --from=production-deps /myapp/node_modules /myapp/node_modules 0.0s
=> CACHED [stage-4 3/6] COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma 0.0s
=> CACHED [stage-4 4/6] COPY --from=build /myapp/build /myapp/build 0.0s
=> CACHED [stage-4 5/6] COPY --from=build /myapp/public /myapp/public 0.0s
=> [stage-4 6/6] ADD . . 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:fcac225c6b1c28a448c676869d2dfecd7d54abf1a4b5711928c52681b6e2ef3f 0.0s
=> => naming to registry.fly.io/my-sch:deployment-01GP53C5MJD6TDF4GTQFH2XGHA 0.0s
→ Building image done
==> Pushing image to fly
The push refers to repository [registry.fly.io/my-sch]
1e14069bcda0: Pushed
7b890d2cd79c: Pushed
43cff887aca4: Pushed
48a25ae845cf: Pushed
79327884a40d: Pushed
757eea636ecb: Pushed
27f607a7d34c: Pushed
8d566ec43bb3: Pushed
68095da5b3da: Pushed
f1ca69e2f614: Pushed
f41277d3eaf4: Pushed
8a70d251b653: Pushed
deployment-01GP53C5MJD6TDF4GTQFH2XGHA: digest: sha256:27219668489305a9d845c4c8c181404e29829966975f5156e2aa7de070878878 size: 2841
→ Pushing image done
image: registry.fly.io/my-sch:deployment-01GP53C5MJD6TDF4GTQFH2XGHA
image size: 421 MB
==> Creating release
→ release v2 created

→ You can detach the terminal anytime without stopping the deployment
==> Monitoring deployment
Logs: Sign In · Fly

1 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
Failed Instances

Failure #1

Instance
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
0f58bb74 app 0 cdg run failed 1 total 2 41s ago

Recent Events
TIMESTAMP TYPE MESSAGE
2023-01-07T03:12:02Z Received Task received by client
2023-01-07T03:12:02Z Task Setup Building Task Directory
2023-01-07T03:12:23Z Started Task started by client
2023-01-07T03:12:27Z Terminated Exit Code: 1
2023-01-07T03:12:27Z Restarting Task restarting in 1.008263789s
2023-01-07T03:12:35Z Started Task started by client
2023-01-07T03:12:39Z Terminated Exit Code: 1
2023-01-07T03:12:39Z Restarting Task restarting in 1.090345751s
2023-01-07T03:12:48Z Started Task started by client
2023-01-07T03:12:52Z Terminated Exit Code: 1
2023-01-07T03:12:52Z Not Restarting Exceeded allowed attempts 2 in interval 5m0s and mode is “fail”
2023-01-07T03:12:52Z Alloc Unhealthy Unhealthy because of failed task
2023-01-07T03:12:53Z Killing Sent interrupt. Waiting 5s before force killing

2023-01-07T03:12:46Z [info]Pulling container image
2023-01-07T03:12:47Z [info]Unpacking image
2023-01-07T03:12:47Z [info]Preparing kernel init
2023-01-07T03:12:48Z [info]Configuring firecracker
2023-01-07T03:12:48Z [info]Starting virtual machine
2023-01-07T03:12:48Z [info]Starting init (commit: f447594)…
2023-01-07T03:12:48Z [info]Preparing to run: docker-entrypoint.sh npm start as root
2023-01-07T03:12:48Z [info]2023/01/07 03:12:48 listening on [fdaa:1:168c:a7b:aec1:f58:bb74:2]:22 (DNS: [fdaa::3]:53)
2023-01-07T03:12:49Z [info]> start
2023-01-07T03:12:49Z [info]> cross-env NODE_ENV=production node ./build/server.js
2023-01-07T03:12:50Z [info]Error: Cannot find module ‘@prisma/client’
2023-01-07T03:12:50Z [info]Require stack:
2023-01-07T03:12:50Z [info]- /myapp/build/index.js
2023-01-07T03:12:50Z [info]- /myapp/build/server.js
2023-01-07T03:12:50Z [info] at Function.Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
2023-01-07T03:12:50Z [info] at Function.Module._load (node:internal/modules/cjs/loader:841:27)
2023-01-07T03:12:50Z [info] at Module.require (node:internal/modules/cjs/loader:1067:19)
2023-01-07T03:12:50Z [info] at require (node:internal/modules/cjs/helpers:103:18)
2023-01-07T03:12:50Z [info] at Object. (/myapp/build/index.js:84:21)
2023-01-07T03:12:50Z [info] at Module._compile (node:internal/modules/cjs/loader:1165:14)
2023-01-07T03:12:50Z [info] at Object.Module._extensions…js (node:internal/modules/cjs/loader:1219:10)
2023-01-07T03:12:50Z [info] at Module.load (node:internal/modules/cjs/loader:1043:32)
2023-01-07T03:12:50Z [info] at Function.Module._load (node:internal/modules/cjs/loader:878:12)
2023-01-07T03:12:50Z [info] at Module.require (node:internal/modules/cjs/loader:1067:19)
2023-01-07T03:12:50Z [info]npm notice
2023-01-07T03:12:50Z [info]npm notice New major version of npm available! 8.19.3 → 9.2.0
2023-01-07T03:12:50Z [info]npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.2.0
2023-01-07T03:12:50Z [info]npm notice Run npm install -g npm@9.2.0 to update!
2023-01-07T03:12:50Z [info]npm notice
2023-01-07T03:12:50Z [info]Starting clean up.
→ v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v1

→ Troubleshooting guide at Troubleshooting your Deployment · Fly Docs
Error abort

Hi,

The first mention of an error seems to be when it can’t find @prisma/client. So that would be where I’d start my debugging. Is it actually installed :thinking:? The line above sets NODE_ENV as production, meaning dev dependencies won’t be installed. If @prisma/client is a dev dependency, that would be the problem.

Other people have found that too with Remix:

I am getting Invariant error now

Logs: Sign In · Fly

1 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
Failed Instances

Failure #1

Instance
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
c8a66f0f app 1 cdg run pending 1 total 2 26s ago

Recent Events
TIMESTAMP TYPE MESSAGE
2023-01-08T01:22:52Z Received Task received by client
2023-01-08T01:22:52Z Task Setup Building Task Directory
2023-01-08T01:23:00Z Started Task started by client
2023-01-08T01:23:04Z Terminated Exit Code: 1
2023-01-08T01:23:04Z Restarting Task restarting in 1.230008622s
2023-01-08T01:23:12Z Started Task started by client
2023-01-08T01:23:16Z Terminated Exit Code: 1
2023-01-08T01:23:16Z Restarting Task restarting in 1.074788561s

2023-01-08T01:23:13Z [info] at require (node:internal/modules/cjs/helpers:103:18)
2023-01-08T01:23:13Z [info] at Object. (/myapp/build/server.js:41713:77)
2023-01-08T01:23:14Z [info]Starting clean up.
2023-01-08T01:23:21Z [info]Starting instance
2023-01-08T01:23:23Z [info]Configuring virtual machine
2023-01-08T01:23:23Z [info]Pulling container image
2023-01-08T01:23:23Z [info]Unpacking image
2023-01-08T01:23:23Z [info]Preparing kernel init
2023-01-08T01:23:24Z [info]Configuring firecracker
2023-01-08T01:23:24Z [info]Starting virtual machine
2023-01-08T01:23:24Z [info]Starting init (commit: f447594)…
2023-01-08T01:23:24Z [info]Preparing to run: docker-entrypoint.sh npm start as root
2023-01-08T01:23:24Z [info]2023/01/08 01:23:24 listening on [fdaa:1:168c:a7b:aebf:c8a6:6f0f:2]:22 (DNS: [fdaa::3]:53)
2023-01-08T01:23:25Z [info]> start
2023-01-08T01:23:25Z [info]> cross-env NODE_ENV=production node ./build/server.js
2023-01-08T01:23:26Z [info]/myapp/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10
2023-01-08T01:23:26Z [info] throw new Error(prefix);
2023-01-08T01:23:26Z [info]js.js:10:15)
2023-01-08T01:23:26Z [info]Error: Invariant failed
2023-01-08T01:23:26Z [info] at invariant (/myapp/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10:15)
2023-01-08T01:23:26Z [info] at getClient (/myapp/build/index.js:88:37)
2023-01-08T01:23:26Z [info] at Object. (/myapp/build/index.js:85:10)
2023-01-08T01:23:26Z [info] at Module._compile (node:internal/modules/cjs/loader:1165:14)
2023-01-08T01:23:26Z [info] at Object.Module._extensions…js (node:internal/modules/cjs/loader:1219:10)
2023-01-08T01:23:26Z [info] at Module.load (node:internal/modules/cjs/loader:1043:32)
2023-01-08T01:23:26Z [info] at Function.Module._load (node:internal/modules/cjs/loader:878:12)
2023-01-08T01:23:26Z [info] at Module.require (node:internal/modules/cjs/loader:1067:19)
2023-01-08T01:23:26Z [info] at require (node:internal/modules/cjs/helpers:103:18)
2023-01-08T01:23:26Z [info] at Object. (/myapp/build/server.js:41713:77)
2023-01-08T01:23:26Z [info]Starting clean up.
→ v1 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v2

→ Troubleshooting guide at Troubleshooting your Deployment · Fly Docs
Error abort

Hmm. Not sure why that would be.

Do you have all the expected environment variables set? You can set non-secret ones in your fly.toml in an [env] block. Secrets should be set in advance of deploying by using fly secrets set NAME=VALUE.

They will then be staged for deployment. And then run fly deploy. For example:

Logs: Sign In · Fly

1 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
Failed Instances

Failure #1

Instance
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
c8a66f0f app 1 cdg run pending 1 total 2 26s ago

Recent Events
TIMESTAMP TYPE MESSAGE
2023-01-08T01:22:52Z Received Task received by client
2023-01-08T01:22:52Z Task Setup Building Task Directory
2023-01-08T01:23:00Z Started Task started by client
2023-01-08T01:23:04Z Terminated Exit Code: 1
2023-01-08T01:23:04Z Restarting Task restarting in 1.230008622s
2023-01-08T01:23:12Z Started Task started by client
2023-01-08T01:23:16Z Terminated Exit Code: 1
2023-01-08T01:23:16Z Restarting Task restarting in 1.074788561s

2023-01-08T01:23:13Z [info] at require (node:internal/modules/cjs/helpers:103:18)
2023-01-08T01:23:13Z [info] at Object. (/myapp/build/server.js:41713:77)
2023-01-08T01:23:14Z [info]Starting clean up.
2023-01-08T01:23:21Z [info]Starting instance
2023-01-08T01:23:23Z [info]Configuring virtual machine
2023-01-08T01:23:23Z [info]Pulling container image
2023-01-08T01:23:23Z [info]Unpacking image
2023-01-08T01:23:23Z [info]Preparing kernel init
2023-01-08T01:23:24Z [info]Configuring firecracker
2023-01-08T01:23:24Z [info]Starting virtual machine
2023-01-08T01:23:24Z [info]Starting init (commit: f447594)…
2023-01-08T01:23:24Z [info]Preparing to run: docker-entrypoint.sh npm start as root
2023-01-08T01:23:24Z [info]2023/01/08 01:23:24 listening on [fdaa:1:168c:a7b:aebf:c8a6:6f0f:2]:22 (DNS: [fdaa::3]:53)
2023-01-08T01:23:25Z [info]> start
2023-01-08T01:23:25Z [info]> cross-env NODE_ENV=production node ./build/server.js
2023-01-08T01:23:26Z [info]/myapp/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10
2023-01-08T01:23:26Z [info] throw new Error(prefix);
2023-01-08T01:23:26Z [info]js.js:10:15)
2023-01-08T01:23:26Z [info]Error: Invariant failed
2023-01-08T01:23:26Z [info] at invariant (/myapp/node_modules/tiny-invariant/dist/tiny-invariant.cjs.js:10:15)
2023-01-08T01:23:26Z [info] at getClient (/myapp/build/index.js:88:37)
2023-01-08T01:23:26Z [info] at Object. (/myapp/build/index.js:85:10)
2023-01-08T01:23:26Z [info] at Module._compile (node:internal/modules/cjs/loader:1165:14)
2023-01-08T01:23:26Z [info] at Object.Module._extensions…js (node:internal/modules/cjs/loader:1219:10)
2023-01-08T01:23:26Z [info] at Module.load (node:internal/modules/cjs/loader:1043:32)
2023-01-08T01:23:26Z [info] at Function.Module._load (node:internal/modules/cjs/loader:878:12)
2023-01-08T01:23:26Z [info] at Module.require (node:internal/modules/cjs/loader:1067:19)
2023-01-08T01:23:26Z [info] at require (node:internal/modules/cjs/helpers:103:18)
2023-01-08T01:23:26Z [info] at Object. (/myapp/build/server.js:41713:77)
2023-01-08T01:23:26Z [info]Starting clean up.
→ v1 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v2

→ Troubleshooting guide at Troubleshooting your Deployment · Fly Docs
Error abort