I am having an issue to deploy a Remix app I was able to deploy in the past. I am using Prisma and following the recommendation using a swap file.
Here is the errog log showed during the deployment:
-------
✖ release_command failed
-------
Error release_command failed running on machine 90801936b20908 with exit code 134.
Check its logs: here's the last 100 lines below, or run 'fly logs -i 90801936b20908':
Pulling container image registry.fly.io/****:deployment-01HWTSVM53JY8W68W8WGNEETEE
Successfully prepared image registry.fly.io/****:deployment-01HWTSVM53JY8W68W8WGNEETEE (7.056954017s)
Configuring firecracker
[ 0.037002] PCI: Fatal: No config space access function found
INFO Starting init (commit: c1e2693b)...
INFO Preparing to run: `docker-entrypoint.sh bash ./scripts/migrate.sh` as root
INFO [fly api proxy] listening at /.fly/api
2024/05/01 19:28:16 INFO SSH listening listen_address=[fdaa:0:648d:a7b:40:f30f:e9c7:2]:22 dns_server=[fdaa::3]:53
Machine created and started in 9.024s
fallocate: fallocate failed: Text file busy
mkswap: error: /swapfile is mounted; will not make swapspace
swapon: /swapfile: swapon failed: Device or resource busy
npm WARN exec The following package was not found and will be installed: prisma@5.13.0
<--- Last few GCs --->
[315:0x6682850] 14315 ms: Scavenge (reduce) 253.5 (257.7) -> 253.4 (258.5) MB, 21.1 / 0.0 ms (average mu = 0.668, current mu = 0.728) allocation failure;
[315:0x6682850] 14858 ms: Mark-sweep (reduce) 254.4 (258.5) -> 254.1 (259.5) MB, 379.1 / 0.0 ms (+ 190.7 ms in 30 steps since start of marking, biggest step 16.9 ms, walltime since start of marking 799 ms) (average mu = 0.585, current mu = 0.501) allo
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0xb9a330 node::Abort() [npm exec prisma migrate deploy]
2: 0xaa07ee [npm exec prisma migrate deploy]
3: 0xd71ed0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [npm exec prisma migrate deploy]
4: 0xd72277 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [npm exec prisma migrate deploy]
5: 0xf4f635 [npm exec prisma migrate deploy]
6: 0xf61b0d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [npm exec prisma migrate deploy]
7: 0xf3c1fe v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [npm exec prisma migrate deploy]
8: 0xf3d5c7 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [npm exec prisma migrate deploy]
9: 0xf1dff2 v8::internal::Factory::AllocateRawWithAllocationSite(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [npm exec prisma migrate deploy]
10: 0xf2884c v8::internal::Factory::NewJSObjectFromMap(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [npm exec prisma migrate deploy]
11: 0x1057e05 v8::internal::JsonParser<unsigned short>::BuildJsonObject(v8::internal::JsonParser<unsigned short>::JsonContinuation const&, v8::base::SmallVector<v8::internal::JsonProperty, 16ul, std::allocator<v8::internal::JsonProperty> > const&, v8::internal::Handle<v8::internal::Map>) [npm exec prisma migrate deploy]
12: 0x1059a88 v8::internal::JsonParser<unsigned short>::ParseJsonValue() [npm exec prisma migrate deploy]
13: 0x105a19f v8::internal::JsonParser<unsigned short>::ParseJson() [npm exec prisma migrate deploy]
14: 0xdf7983 v8::internal::Builtin_JsonParse(int, unsigned long*, v8::internal::Isolate*) [npm exec prisma migrate deploy]
15: 0x1710839 [npm exec prisma migrate deploy]
./scripts/migrate.sh: line 9: 315 Aborted npx prisma migrate deploy
INFO Main child exited normally with code: 134
INFO Starting clean up.
[ 16.374888] reboot: Restarting system
machine restart policy set to 'no', not restarting
-------
Checking DNS configuration for *****.fly.dev
Error: release command failed - aborting deployment. error release_command machine 90801936b20908 exited with non-zero status of 134
Here are the key errors: PCI: Fatal: No config space access function found
fallocate: fallocate failed: Text file busy
mkswap: error: /swapfile is mounted; will not make swapspace
swapon: /swapfile: swapon failed: Device or resource busy
Can you share the contents of this file? The fix is likely to remove a bunch of lines in that file that set up swap, and add one line to your fly.toml: Fly Launch configuration (fly.toml) · Fly Docs
I think you need to make that number bigger, and perhaps only want to set it for release. My read is that without that option, node is not taking advantage of swap, and you need to tell it that it can use more.
It also may be worth experimenting with increasing real memory - which is faster, but a paid feature. But the charges are only while in use, so trying it briefly shouldn’t be expensive:
We’ve had success asking people to use this in their fly.toml or set that node options variable elsewhere if suitable:
[env]
NODE_OPTIONS='--max-old-space-size=4096'
The above was tested on a 512MB system.
As Sam mentioned, this doesn’t mean it’ll require 4GB of physical RAM, it just tells node it can use up to 4GB. Note that if it does try to use more it’ll rightfully OOM, but that would be an OS-level OOM and not a node-level “the configured heap is too small even if there’s enough physical memory for more”.