Deploy failures for Node app, and how I solved them

No help needed. Posting this on the community site to help other Fly users who may run into the same issues.

Last time I deployed our Node app to Fly was a few months ago. Has been running fine.
Yesterday, I added 2 regions in US and that went well.
Then, I tried to deploy new version of our super simple Node app (works fine on local) with flyctl deploy and this failed:

Executing build process
    npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
    cdnplanet-nodes@0.0.1 /workspace
    `-- UNMET DEPENDENCY follow-redirects@1.14.1
    
    npm ERR! missing: follow-redirects@1.14.1, required by cdnplanet-nodes@0.0.1
    
vendored node_modules have unmet dependencies: npm list failed: exit status 1

Upgraded Node and npm on local machine, specified Node and npm versions in package.json so to ‘force’ the paketo buildpack to use those Node and npm versions.
This solved the issue.

But, deploys still fail.
Tried several times, snippet of last attempt’s output in terminal:

...
--> Building image done
==> Pushing image to fly
...
--> Pushing image done
...
==> Creating release
Release v16 created

You can detach the terminal anytime without stopping the deployment
Monitoring Deployment

3 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
v16 failed - Failed due to unhealthy allocations - rolling back to job version 15
Failed Instances

==> Failure #1

Instance
  ID            = 5790e9d5  
  Version       = 16        
  Region        = dfw       
  Desired       = run       
  Status        = running   
  Health Checks = 1 total   
  Restarts      = 2         
  Created       = 19s ago   

Recent Events
TIMESTAMP            TYPE       MESSAGE                         
2021-07-17T09:40:23Z Received   Task received by client         
2021-07-17T09:40:23Z Task Setup Building Task Directory         
2021-07-17T09:40:32Z Started    Task started by client          
2021-07-17T09:40:34Z Terminated Exit Code: 1                    
2021-07-17T09:40:34Z Restarting Task restarting in 1.169324475s 
2021-07-17T09:40:36Z Started    Task started by client          
2021-07-17T09:40:38Z Terminated Exit Code: 1                    
2021-07-17T09:40:38Z Restarting Task restarting in 1.225115656s 
2021-07-17T09:40:41Z Started    Task started by client          

Recent Logs
2021-07-17T09:40:37Z [info]     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
2021-07-17T09:40:37Z [info]     at node:internal/main/run_main_module:17:47 {
2021-07-17T09:40:37Z [info]   code: 'MODULE_NOT_FOUND',
2021-07-17T09:40:37Z [info]   requireStack: []
2021-07-17T09:40:37Z [info] }
2021-07-17T09:40:37Z [info] Main child exited normally with code: 1
2021-07-17T09:40:37Z [info] Starting clean up.
2021-07-17T09:40:40Z [info] Starting instance
2021-07-17T09:40:40Z [info] Configuring virtual machine
2021-07-17T09:40:40Z [info] Pulling container image
2021-07-17T09:40:40Z [info] Unpacking image
2021-07-17T09:40:40Z [info] Preparing kernel init
2021-07-17T09:40:40Z [info] Configuring firecracker
2021-07-17T09:40:40Z [info] Starting virtual machine
2021-07-17T09:40:41Z [info] Starting init (commit: cc4f071)...
2021-07-17T09:40:41Z [info] Running: `/cnb/process/web` as 1000
2021-07-17T09:40:41Z [info] 2021/07/17 09:40:41 listening on [fdaa:0:1f78:a7b:7f:5790:e9d5:2]:22 (DNS: [fdaa::3]:53)
2021-07-17T09:40:41Z [info] node:internal/modules/cjs/loader:930
2021-07-17T09:40:41Z [info]   throw err;
2021-07-17T09:40:41Z [info]   ^
2021-07-17T09:40:41Z [info] Error: Cannot find module '/workspace/server.js'
2021-07-17T09:40:41Z [info]     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)
2021-07-17T09:40:41Z [info]     at Function.Module._load (node:internal/modules/cjs/loader:772:27)
2021-07-17T09:40:41Z [info]     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
2021-07-17T09:40:41Z [info]     at node:internal/main/run_main_module:17:47 {
2021-07-17T09:40:41Z [info]   code: 'MODULE_NOT_FOUND',
2021-07-17T09:40:41Z [info]   requireStack: []
2021-07-17T09:40:41Z [info] }
2021-07-17T09:40:42Z [info] Main child exited normally with code: 1
2021-07-17T09:40:42Z [info] Starting clean up.

3 desired, 1 placed, 0 healthy, 1 unhealthy [restarts: 2] [health checks: 1 total]
v17 failed - Failed due to unhealthy allocations - not rolling back to stable job version 17 as current job has same specification
Failed Instances

==> Failure #1

Instance
  ID            = 3326f1a7  
  Version       = 17        
  Region        = dfw       
  Desired       = run       
  Status        = pending   
  Health Checks = 1 total   
  Restarts      = 2         
  Created       = 10s ago   

Recent Events
TIMESTAMP            TYPE       MESSAGE                         
2021-07-17T09:40:43Z Received   Task received by client         
2021-07-17T09:40:43Z Task Setup Building Task Directory         
2021-07-17T09:40:45Z Started    Task started by client          
2021-07-17T09:40:47Z Terminated Exit Code: 1                    
2021-07-17T09:40:47Z Restarting Task restarting in 1.072133118s 
2021-07-17T09:40:49Z Started    Task started by client          
2021-07-17T09:40:51Z Terminated Exit Code: 1                    
2021-07-17T09:40:51Z Restarting Task restarting in 1.185686784s 

Recent Logs
2021-07-17T09:40:49Z [info]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-07-17T09:40:49Z [info]     at internal/main/run_main_module.js:17:47 {
2021-07-17T09:40:49Z [info]   code: 'MODULE_NOT_FOUND',
2021-07-17T09:40:49Z [info]   requireStack: []
2021-07-17T09:40:49Z [info] }
2021-07-17T09:40:50Z [info] Main child exited normally with code: 1
2021-07-17T09:40:50Z [info] Starting clean up.
2021-07-17T09:40:52Z [info] Starting instance
2021-07-17T09:40:52Z [info] Configuring virtual machine
2021-07-17T09:40:52Z [info] Pulling container image
2021-07-17T09:40:52Z [info] Unpacking image
2021-07-17T09:40:52Z [info] Preparing kernel init
2021-07-17T09:40:53Z [info] Configuring firecracker
2021-07-17T09:40:53Z [info] Starting virtual machine
2021-07-17T09:40:53Z [info] Starting init (commit: cc4f071)...
2021-07-17T09:40:53Z [info] Running: `/cnb/process/web` as 1000
2021-07-17T09:40:53Z [info] 2021/07/17 09:40:53 listening on [fdaa:0:1f78:a7b:7f:3326:f1a7:2]:22 (DNS: [fdaa::3]:53)
2021-07-17T09:40:54Z [info] internal/modules/cjs/loader.js:905
2021-07-17T09:40:54Z [info]   throw err;
2021-07-17T09:40:54Z [info]   ^
2021-07-17T09:40:54Z [info] Error: Cannot find module '/workspace/server.js'
2021-07-17T09:40:54Z [info]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
2021-07-17T09:40:54Z [info]     at Function.Module._load (internal/modules/cjs/loader.js:746:27)
2021-07-17T09:40:54Z [info]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-07-17T09:40:54Z [info]     at internal/main/run_main_module.js:17:47 {
2021-07-17T09:40:54Z [info]   code: 'MODULE_NOT_FOUND',
2021-07-17T09:40:54Z [info]   requireStack: []
2021-07-17T09:40:54Z [info] }
2021-07-17T09:40:54Z [info] Main child exited normally with code: 1
2021-07-17T09:40:54Z [info] Starting clean up.
***v16 failed - Failed due to unhealthy allocations - rolling back to job version 15 and deploying as v17 

Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/

Searched on Google and ended up here on SO: node.js - Error: Cannot find module '/workspace/server.js' - Stack Overflow

Added "start": "node app.js" to my scripts in package.json and this solved the issue.

1 Like

Wow nice find.