# Email-in node occasionally gets stuck fetching

**URL:** https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450
**Category:** General
**Created:** [29 November 2022 13:37 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450 "2022-11-29T13:37:09Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 13:37 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/1 "2022-11-29T13:37:09Z")

</div>

I've been using the email-in node for a few months now. And 3 times now, I have noticed that it has gotten stuck. I haven't looked into it very deeply yet, but I noted it wasn't working all day yesterday, so yesterday evening, I took a look and it had a blue "fetching" label.

I use a cronplus node to trigger it every 60 seconds (so I can manually trigger it occasionally).

I redeployed and all the backed up emails came through. Similarly, the previous couple times, I'd rebooted and it flushed out.

Any tips on how to prevent it from getting into this stuck state or else catch it with a deadman switch and somehow give it a kick?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [29 November 2022 15:14 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/2 "2022-11-29T15:14:42Z")

</div>

How about a countdown timer that gets reset when ever mail comes in. If the timer triggers, have an exec node run a bash script that will stop and start NR?

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 15:41 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/3 "2022-11-29T15:41:42Z")

</div>

Yeah. I'm unfamiliar with the countdown timer, but that's exactly what the `dead-man-switch` node does. It hadn't occurred to me to use exec to restart NR. Doh!

But I might be able to make it a bit smarter... I assume that if I don't receive an email, the email-in node doesn't spit anything out. I get 2 types of emails. One is a very infrequent, but very important email from a water sensor in the basement. Another is a usually frequent email from a security camera (which I ONLY use because it's the only easy way I know of the get a still image from SightHound - that I forward via SMS).

The cam email is always preceded by a webhook call. So I would want to restart NR in the event that the webhook is not followed by an email say, within 2 minutes. I've done designs like this before, but they're a bit clunky. I usually change a flow variable and check it. I could have the email set a flow variable (indicating an email was received). I could have the webhook go into a 2m delay, followed by a check of the flow variable. If it's false (no email received), trigger a restart.

Is there a way to trigger just a redeploy of the flow? Seems a tad overkill to restart NR...

---

<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: [29 November 2022 15:48 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/4 "2022-11-29T15:48:17Z")

</div>

> [@hepcat72](#):
>
> I use a cronplus node to trigger it every 60 seconds

To do an action when something doesn't happen for a while, use a Trigger node.

You can use the admin api post /flows to force a restart flows.

Before going down that route though I suggest slowing the trigger down to 10 minutes. I am wondering if there is a problem meaning that the fetch is stuck, but because you keep retriggering it, it does not have time to timeout. I don't have any evidence to support that but worth trying. Are you using the latest version of the email node?

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 15:59 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/5 "2022-11-29T15:59:04Z")

</div>

Incidentally, I learned the term "deadman switch" via a novel by by that name written by my favorite author (Timmothy Zahn). I do recommend.

I use a 60 second fetch interval because I want to know the reported events as soon as possible: water in the basement and someone at the door. I have a rule set up (using the camera motion trigger and a Wemo motion trigger - each of which individually have many false positives, but together are pretty good) that is fairly reliable (correct about 90% of the time), but when I get that message ("Someone is at the door"), I usually wait a few seconds to see the image come in via text to confirm.

One of the things on my todo is set up pilight to recognize and receive the 433Mhz code from my remote doorbell mechanism to send me that "Someone's at the door" text.

---

<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: [29 November 2022 16:03 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/6 "2022-11-29T16:03:09Z")

</div>

> [@hepcat72](#):
>
> I use a 60 second fetch interval because I want to know the reported events as soon as possible

Next time it happens, remove the input wire from the email node and deploy and wait ten minutes to see if anything happens. Network timeouts can often take a few minutes.

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 16:20 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/7 "2022-11-29T16:20:30Z")

</div>

That's a good point. I do see there's an update for the email-in node (thinking of your previous suggestion). So I just updated it and will issue a restart. `x.17.x` to `x.18.x`. Maybe it will solve the problem and I won't need to implement a mitigation.

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 16:24 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/8 "2022-11-29T16:24:08Z")

</div>

Oh, what the heck. After restart, I see this:

 ![emailinupdate](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0ac7b7ecac2ddd7b5ee62ee5ffa400d4dd64142e.png)  
 ![warningemailin](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6bb88932c0e89f2579dac16d8f6da713b8773f11.png)

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 16:31 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/9 "2022-11-29T16:31:38Z")

</div>

It's in .node-red/node\_modules... So why is it complaining it's missing? I tried a manual "install" on the command line with `npm i node-red-node-email` and it says it's up-to-date.

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 16:40 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/10 "2022-11-29T16:40:46Z")

</div>

Couldn't remove it either:

 ![emailinremovefail](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6d258f5df2f806e5e2b19f0cc7960febd5cdb17.png)

But I managed to resolve it with:

```auto
cd .node-red
npm uninstall node-red-node-email
npm i node-red-node-email
pm2 restart node-red

```

Now it seems to be working.

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 16:46 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/11 "2022-11-29T16:46:40Z")

</div>

Incidentally, where would you find the release notes for the versions? I poked around a bit, but didn't turn them up. The only thing seems to be the git log, but it's not specific to this node (`node-red-nodes`)...

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [29 November 2022 17:11 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/12 "2022-11-29T17:11:28Z")

</div>

Head over to the [blog](https://nodered.org/blog/) and you will find the information

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [29 November 2022 17:15 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/13 "2022-11-29T17:15:50Z")

</div>

Another thought maybe to use the status node to check for fetching and feed a trigger node such that if that doesn’t change after x secs to then restart

( yes this has been reported occasionally but so far it has eluded all attempts to recreate it to see exactly what is sticking and why )

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 18:16 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/14 "2022-11-29T18:16:59Z")

</div>

I'm happy to help debug. If there are some log messages I could uncomment that could for example, reveal an endless loop, or a timeout block I could add, I'm happy to check it out next time it happens...

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [29 November 2022 23:52 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/15 "2022-11-29T23:52:45Z")

</div>

Well, I tried out the test flow from [this thread](https://discourse.nodered.org/t/restart-flows-using-node-red-api/34632/11). Although it contains an `id` to ostensibly restart just the flow with the supplied `id`, it does restart all flows... The docs don't seem to indicate that this is possible, though one dev in the threads said it needed an overhaul in 2020. I don't suppose the overhaul has happened and the docs are outdated? Either way, I'm going to implement the status-watch suggestion and redeploy via a deadman switch on that status node.

---

<div class="post-metadata">

### Author: ![hepcat72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hepcat72/32/8078_2.png) [@hepcat72](https://discourse.nodered.org/u/hepcat72)
#### Post date: [30 November 2022 00:15 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/16 "2022-11-30T00:15:25Z")

</div>

OK. Tests worked. The work-around is live. It will send me an SMS if it ever re-deploys my flows.

![auto-redeploy](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/894067813be9d9f3e62d3e3a6c1e918ebd680683.png)

---

<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: [14 December 2022 00:15 UTC](https://discourse.nodered.org/t/email-in-node-occasionally-gets-stuck-fetching/71450/17 "2022-12-14T00:15:53Z")

</div>

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