# Node-red crash with node-red-contrib-telegrambot-home

**URL:** <https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806>\
**Category:** General\
**Tags:** telegram\
**Created:** [13 March 2022 16:53 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806 "2022-03-13T16:53:37Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![achrafb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achrafb/32/45607_2.png) [@achrafb](https://discourse.nodered.org/u/achrafb)\
**Post date:** [13 March 2022 16:53 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/1 "2022-03-13T16:53:37Z")

</div>

Hi all 🙂

Lately I have been using the nodes: node-red-contrib-telegrambot-home, I have seen that if any user blocks the BOT, the whole Node-red service restarts, I have tried with the catch to receive the error to handle it but it doesn't detect the error:

NR log:

> This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: Error: ETELEGRAM: 403 Forbidden: Bot was blocked by the user at /home/pi/.node-red/node\_modules/node-telegram-bot-api/src/telegram.js:291:15 at tryCatcher (/home/pi/.node-red/node\_modules/bluebird/js/release/util.js:16:23) at Promise.\_settlePromiseFromHandler (/home/pi/.node-red/node\_modules/bluebird/js/release/promise.js:547:31) at Promise.\_settlePromise (/home/pi/.node-red/node\_modules/bluebird/js/release/promise.js:604:18) at Promise.\_settlePromise0 (/home/pi/.node-red/node\_modules/bluebird/js/release/promise.js:649:10) at Promise.\_settlePromises (/home/pi/.node-red/node\_modules/bluebird/js/release/promise.js:729:18) at \_drainQueueStep (/home/pi/.node-red/node\_modules/bluebird/js/release/async.js:93:12) at \_drainQueue (/home/pi/.node-red/node\_modules/bluebird/js/release/async.js:86:9) at Async.\_drainQueues (/home/pi/.node-red/node\_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as \_onImmediate] (/home/pi/.node-red/node\_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:461:21) nodered.service: Main process exited, code=exited, status=1/FAILURE nodered.service: Failed with result 'exit-code'. nodered.service: Service RestartSec=20s expired, scheduling restart. nodered.service: Scheduled restart job, restart counter is at 1.

Has this happened to anyone else? Can I do something to stop the NR service from restarting with this error?

P.S I have opened an issue on github [Node-red crash when trying to send a message to a user who has blocked the BOT · Issue #37 · scraton/node-red-contrib-telegrambot-home · GitHub](https://github.com/scraton/node-red-contrib-telegrambot-home/issues/37#issue-1167402226)

Thanks in Advance for your help

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 March 2022 17:08 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/2 "2022-03-13T17:08:18Z")

</div>

Submitting an issue is the right thing to do, the node should not crash node red on this sort of error.  
I suspect you may get little support though, as there is at least one rather similar issue that has been waiting for a long time to get fixed.

Is there a reason you are using that node rather than node-red-contrib-telegrambot which I think most people use?

---

<div class="post-metadata">

**Author:** ![achrafb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achrafb/32/45607_2.png) [@achrafb](https://discourse.nodered.org/u/achrafb)\
**Post date:** [13 March 2022 17:18 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/3 "2022-03-13T17:18:52Z")

</div>

Thanks for the reply Colin!  
Some time ago I had installed the first thing I had seen and I am sticking with telegrambot-home, due to the fact that I have more than 40 flows using these nodes, and many automated tasks, it would be unfeasible to switch to node-red-contrib-telegrambot as I would have to redo everything ☹

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 March 2022 17:50 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/4 "2022-03-13T17:50:00Z")

</div>

You backed the wrong 🐎

telegrambot is better maintained.

I'm pretty sure telegrambot-home is a clone of telegrambot so might be compatible with your flows.

My guess is you are running on nodejs v16 or higher? As of node16 promises without a catch handler will kill nodejs

> [@achrafb](#):
>
> This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch()

Telegrambot is tested on nodejs 16.

---

<div class="post-metadata">

**Author:** ![achrafb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achrafb/32/45607_2.png) [@achrafb](https://discourse.nodered.org/u/achrafb)\
**Post date:** [13 March 2022 20:06 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/5 "2022-03-13T20:06:30Z")

</div>

> [@Steve-Mcl](#):
>
> you are running on nodejs v16 or higher?

Hi Steve, thank's for your reply, currenty running on: **Node.js v12.22.7**

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 March 2022 20:08 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/6 "2022-03-13T20:08:30Z")

</div>

Hmmm. Strange. I wonder if it is something to do with bluebird promises?

What version of node-red as you on?

---

<div class="post-metadata">

**Author:** ![achrafb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achrafb/32/45607_2.png) [@achrafb](https://discourse.nodered.org/u/achrafb)\
**Post date:** [13 March 2022 20:12 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/7 "2022-03-13T20:12:25Z")

</div>

> [@Steve-Mcl](#):
>
> What version of node-red as you on?

I currently have these versions:

```auto

Node-RED version: v2.1.3
Node.js version: v12.22.7
Linux 5.10.63-v7+ arm LE

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 March 2022 20:25 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/8 "2022-03-13T20:25:35Z")

</div>

Hmmm - odd.

I wonder if this is a clue...

> [@achrafb](#):
>
> ETELEGRAM: 403 Forbidden

Is you bot still active (check in the telegram app/web)?  
Is your key/token correct? (you can see what the token is by sending `/mybots` to botfather)

---

<div class="post-metadata">

**Author:** ![achrafb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achrafb/32/45607_2.png) [@achrafb](https://discourse.nodered.org/u/achrafb)\
**Post date:** [13 March 2022 20:30 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/9 "2022-03-13T20:30:23Z")

</div>

> [@Steve-Mcl](#):
>
> Is you bot still active (check in the telegram app/web)?

Yes my bot is still active and working

It only blocks and restarts the node-red if a user has blocked it and I try to send something:

> [@achrafb](#):
>
> ETELEGRAM: 403 Forbidden: Bot was blocked by the user

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 March 2022 20:37 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/10 "2022-03-13T20:37:05Z")

</div>

We'll have to see if the developer responds to your issue.

It might be worth firing up a 2nd instance of node-red and testing `node-red-contrib-telegrambot` to see if that crashes?

(you can easily fire up additional node-red by entering `node-red -u ~/node-red-1881 -p 1881` then opening it at `http://x.x.x.x:1881`)

---

<div class="post-metadata">

**Author:** ![achrafb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achrafb/32/45607_2.png) [@achrafb](https://discourse.nodered.org/u/achrafb)\
**Post date:** [13 March 2022 21:07 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/11 "2022-03-13T21:07:16Z")

</div>

I have carried out the test with: node-red-contrib-telegrambot

It handles the error correctly, and does not crash or restart the NR service.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/058221cf4f52e7259c56854f0c755d5bf86fe219.png)

I will check if I can modify something in telegrambot-home to handle these errors, and if I can't, I will consider migrating everything to node-red-contrib-telegrambot, which will take me at least a month of work ☹

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 March 2022 21:45 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/12 "2022-03-13T21:45:39Z")

</div>

> [@achrafb](#):
>
> will take me at least a month of work

I find that surprising. Why is it so high?

---

<div class="post-metadata">

**Author:** ![achrafb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achrafb/32/45607_2.png) [@achrafb](https://discourse.nodered.org/u/achrafb)\
**Post date:** [14 March 2022 01:18 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/13 "2022-03-14T01:18:19Z")

</div>

> [@Colin](#):
>
> I find that surprising. Why is it so high?

Counting only weekends when I can migrate flows,

Although in the bot I have hundreds and hundreds of commands and intents, in the database I have 1203 local routes to deliver pdf manuals.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 March 2022 09:32 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/14 "2022-03-14T09:32:47Z")

</div>

Hmm, sounds like some kind of chatbot implementation? They can get out of hand really quickly.

Have you looked at [rivescript](https://flows.nodered.org/search?term=rivescript) at all? That can be really helpful in dealing with chatty interfaces.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 May 2022 09:33 UTC](https://discourse.nodered.org/t/node-red-crash-with-node-red-contrib-telegrambot-home/59806/15 "2022-05-13T09:33:42Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
