如何修复Heroku错误:Process exited with status 129及Error R13
Hey, let's tackle those errors you're seeing with your Telegram bot on Heroku. You mentioned you fixed the SIGKILL issues, but now running node musicology.js is throwing exit status 129 and an R13 attach error. Let's break this down step by step.
First, here's the log output you shared for context:
2018-05-14T09:12:46.770011+00:00 app[api]: Starting process with command
node musicology.jsby user leshaber24@yandex.ru
2018-05-14T09:12:50.704836+00:00 heroku[run.5756]: Awaiting client
2018-05-14T09:12:50.760658+00:00 heroku[run.5756]: Starting process with commandnode musicology.js
2018-05-14T09:12:50.767575+00:00 heroku[run.5756]: State changed from starting to up
2018-05-14T09:12:56.951346+00:00 heroku[run.5756]: Client connection closed. Sending SIGHUP to all processes
2018-05-14T09:12:57.484760+00:00 heroku[run.5756]: Process exited with status 129
2018-05-14T09:12:57.499531+00:00 heroku[run.5756]: State changed from up to complete
What's Causing This?
Looking at the logs, the key line is Client connection closed. Sending SIGHUP to all processes. Exit status 129 is tied to the SIGHUP signal, which Heroku sends when the interactive client connection (from heroku run) drops. Error R13 is just Heroku telling you it couldn't maintain that attach connection to your process.
The core issue here is that heroku run is designed for one-off interactive commands, not long-running processes like a Telegram bot that needs to stay alive in the background. When you close your local terminal or the session times out, Heroku sends that SIGHUP and kills your bot.
Fixes to Try
Use a Worker Dyno (The Right Way to Run Long-Living Processes)
- Create a
Procfilein your project root (no file extension) with this line:worker: node musicology.js - Commit this file to your repo and push to Heroku.
- Scale up the worker dyno to start your bot as a persistent background process:
heroku ps:scale worker=1 - This way, your bot runs independently of your local terminal session and won't get killed when you disconnect.
- Create a
Run Without Attaching (If You Need a Temporary Session)
- If you just want to test the bot temporarily with
heroku run, add the--no-attachflag to avoid the attach error:heroku run node musicology.js --no-attach - This starts the process without tying it to your local client, so it won't receive a SIGHUP when you close your terminal. You can still view logs with
heroku logs --tailto monitor it.
- If you just want to test the bot temporarily with
Check for Interactive Dependencies
- Make sure your bot isn't expecting any interactive input (like a command-line prompt) that would cause it to hang or exit when running non-interactively. All configuration (like your Telegram bot token) should be set via Heroku environment variables:
heroku config:set TELEGRAM_BOT_TOKEN=your_bot_token_here - Also, confirm your
package.jsonhas all required dependencies and specifies a compatible Node.js version (add this if missing):"engines": { "node": "16.x" }
- Make sure your bot isn't expecting any interactive input (like a command-line prompt) that would cause it to hang or exit when running non-interactively. All configuration (like your Telegram bot token) should be set via Heroku environment variables:
Verify Dyno Resources
- Even though you fixed the SIGKILL error, double-check that your worker dyno has enough memory. Use
heroku psor the Heroku dashboard to monitor memory usage—if you're hitting limits, you might need to upgrade to a larger dyno size.
- Even though you fixed the SIGKILL error, double-check that your worker dyno has enough memory. Use
内容的提问来源于stack exchange,提问作者Bereznyak

