grammyjs / grammY

The Telegram Bot Framework.
https://grammy.dev
MIT License
2.21k stars 110 forks source link

node simply ends process soon after trying to run my bot #382

Closed amanape closed 1 year ago

amanape commented 1 year ago

Everything was working fine earlier today, I run tsc and then node dist/bot.js to run my bot. Then, after deleting node_modules and reinstalling the deps, node immediately ends the process after a second of starting without any error or warning.

yarn run dev

RESPONSE:

yarn run v1.22.19
$ tsc && node dist/bot.js
✨  Done in 1.28s.

The strangest thing of all is that the same behaviour persists even if I replace all the source code in my main bot.ts file with the most basic example

import { Bot } from "grammy";

const TOKEN = ""
const bot = new Bot(TOKEN);

// Reply to any message with "Hi there!".
bot.on("message", (ctx) => ctx.reply("Hi there!"));

bot.start();

package.json

{
  "license": "MIT",
  "version": "0.2.0",
  "scripts": {
    "dev": "tsc && node dist/bot.js",
    "build": "tsc"
  },
  "devDependencies": {
    "typescript": "^4.9.5",
    "vite": "^4.1.4",
    "vitest": "^0.28.5"
  },
  "dependencies": {
    "@grammyjs/conversations": "^1.1.1",
    "@grammyjs/files": "^1.0.4",
    "@types/exceljs": "^1.3.0",
    "grammy": "^1.14.1"
  }
}

Could it be something related to my account or token itself? I tried generating new ones, and node just ended in 3 seconds instead of 1 second but only on the first time I run the command.

amanape commented 1 year ago

Running DEBUG='*' node dist/bot.js gives me

  grammy:bot Initializing bot +0ms
  grammy:core Calling getMe +0ms
  grammy:bot I am BT11829Bot! +285ms
  grammy:core Calling deleteWebhook +285ms
jjjj222 commented 1 year ago

I faced the same issue (v1.15.0). Solved by using v1.14.1 instead.

felixniemeyer commented 1 year ago

I have the same issue regardless of whether I'm using nodemon or deno

[nodemon] clean exit - waiting for changes before restart
esindger commented 1 year ago

The problem is in this line.

KnorpelSenf commented 1 year ago

Right, that was stupid. You found it, do you quickly wanna fix it?

KnorpelSenf commented 1 year ago

@all-contributors add @amanape for bug

allcontributors[bot] commented 1 year ago

@KnorpelSenf

I've put up a pull request to add @amanape! :tada:

KnorpelSenf commented 1 year ago

I'll take this then.

KnorpelSenf commented 1 year ago

Please review #384.