Fatal process OOM in Failed to reserve virtual memory for CodeRange

I am trying to deploy a discord bot, I created my app in TS. When I issue fly launch I am having following error

[INFO] Node.js Buildpack
[INFO] Setting NODE_ENV to production
[INFO] Installing toolbox
[INFO] - yj

[Installing Node]
[INFO] Getting Node version
[INFO] Resolving Node version
[INFO] Downloading and extracting Node v16.13.0

[Parsing package.json]
[INFO] Parsing package.json
[INFO] No file to start server
[INFO] either use 'docker run' to start container or add index.js or server.js

# Fatal process OOM in Failed to reserve virtual memory for CodeRange

qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
ERROR: failed to build: exit status 133
Error executing lifecycle: failed with status code: 51

my package.json script files

  "scripts": {
    "start": "npm run cbinary & npm run build && node build/app.js",
    "dev": "nodemon src/app.ts",
    "build": "tsc --build",
    "lint": "eslint . --ext .ts",
    "cbinary": "cp src/main build/main"

can anybody points me out what am I doing wrong?

It seems like the compilation / build phase needs more memory. If this is running on a Fly builder, you could try passing —local-only to finish the build on your local machine.

thanks @sudhir.j I issued following command,

flyctl deploy --local-only

I am still having the same problem. I will paste contents of my fly.toml file

app = "twilight-frog-9274"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

  builder = "heroku/buildpacks:20"

  PORT = "8080"

  allowed_public_ports = []
  auto_rollback = true

  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

    hard_limit = 25
    soft_limit = 20
    type = "connections"

    handlers = ["http"]
    port = 80

    handlers = ["tls", "http"]
    port = 443

    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

These are my dependencies

  "devDependencies": {
    "@tsconfig/node16": "^1.0.2",
    "@types/jsdom": "^16.2.13",
    "@types/node": "^16.11.6",
    "@typescript-eslint/eslint-plugin": "^5.3.0",
    "@typescript-eslint/parser": "^5.3.0",
    "eslint": "^8.2.0",
    "nodemon": "^2.0.14",
    "ts-node": "^10.4.0",
    "typescript": "^4.4.4"
  "dependencies": {
    "@discordjs/builders": "^0.8.2",
    "@discordjs/rest": "^0.1.0-canary.0",
    "discord-api-types": "^0.24.0",
    "discord.js": "^13.3.1",
    "dotenv": "^10.0.0",
    "jsdom": "^18.1.0",
    "phishy": "^0.0.1",
    "safe-browse-url-lookup": "^0.1.1"

I think this is a different issue: Docker build fails when targeting `--platform linux/amd64`, due to `allocate virtual memory` issue · Issue #5831 · docker/for-mac · GitHub

This is a qemu bug on m1 Macs with Docker. --local-only won’t fix it, that just forces it to happen again. Try running fly deploy --remote-only. This will use a Docker daemon running on Fly and avoid any qemu Docker weirdness on an m1.

thanks @kurt I restarted my docker deamon and removed existing images and it worked for me but I think you are righ there is some compatiblity issues with M1. Is there any lighter image that I can use for node.js projects ? or do I have to write my own dockerfile if I want smaller footprint

You probably need your own Dockerfile for a node based Discord bot. I don’t think it’s all that hard, though! This one might work with some tweaks.

FROM node:current-slim
WORKDIR /app			
COPY package.json .
COPY package-lock.json .
RUN npm install --production
COPY . .
RUN npm run build --if-present
CMD [ "npm","start" ]