'my discord bot works well for a while but then "failed to bind to $PORT within 60 seconds of launch"

I've tried different approaches and looked at all the other replies but i dont know how to adress it

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2022-03-19T09:15:18.022903+00:00 heroku[web.1]: Stopping process with SIGKILL 2022-03-19T09:15:18.059850+00:00 app[web.1]: Error waiting for process to terminate: No child processes 2022-03-19T09:15:18.210022+00:00 heroku[web.1]: Process exited with status 22 2022-03-19T09:15:18.331083+00:00 heroku[web.1]: State changed from starting to crashed

the code:

require('dotenv').config();
const OpenAI = require('openai-api');
const openai = new OpenAI(process.env.OPENAI_API_KEY);
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

let prompt =`text here`;

client.on("message", function (message) {
    if (message.author.bot) return;
    prompt += `You: ${message.content}\n`;
    (async () => {
        const gptResponse = await openai.complete({
            engine: 'davinci',
            prompt: prompt,
            maxTokens: 80,
            temperature: 0.7,
            topP: 1,
            presencePenalty: 0,
            frequencyPenalty: 0,
            bestOf: 1,
            n: 1,
            stream: false,
            stop: ['\n', '\n\n']
        });
        message.reply(`${gptResponse.data.choices[0].text.substring(5)}`);
        prompt += `${gptResponse.data.choices[0].text}\n`;
    })();
});     

client.login(process.env.BOT_TOKEN);

my procfile is empty but it still works for 60 seconds any ideas? edit: THINGS I TRIED THAT DONT WORK i tried changing procfile to contain

worker:  node index.js

procfile to worker: java -jar build/libs/*.jar



Solution 1:[1]

Use the name Procfile instead of procfile, otherwise heroku doesn't learns that you need worker process and not the default web process.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rovel Stars