# Help with API fetch() requests never ending when server offline

**URL:** <https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212>\
**Category:** Dev/API Corner\
**Tags:** server-windows, other-dev\
**Created:** [June 18, 2021, 1:51am UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212 "2021-06-18T01:51:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alxwlfe](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/alxwlfe/32/243388_2.png) [@alxwlfe](https://forums.plex.tv/u/alxwlfe)\
**Post date:** [June 18, 2021, 1:51am UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/1 "2021-06-18T01:51:12Z")

</div>

Hi all, hoping someone can point me in the right direction as I’m struggling to find a solution:

- I’m using Airtable Automations + scripts (JavaScript) to grab my latest watched media and send to Trakt via a script (I don’t have Plex Pass otherwise webhooks would solve most of my problem here)
- The script checks for updates every hour
- However, if/when the server is offline (e.g., my PC is turned off, or my power cuts out), it causes the script to fail, but has no response/error codes; it just times itself out since it can’t reach the “[https://ip](https://ip):port”

Any advice on how I can fail this gracefully?

I’ve tried try…catch blocks or similar and feel like I’m not finding anything to address this very specific thing. I’m also new to networking / scripting, but hoping someone here may have done something like this before. Cheers!

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [June 18, 2021, 10:13am UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/2 "2021-06-18T10:13:56Z")

</div>

> [@alxwlfe](#):
>
> Airtable Automations + scripts

Unknown to me, but normally with JS you can specify a timeout

> <https://stackoverflow.com/questions/36690451/timeout-feature-in-the-axios-library-is-not-working>

---

<div class="post-metadata">

**Author:** ![alxwlfe](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/alxwlfe/32/243388_2.png) [@alxwlfe](https://forums.plex.tv/u/alxwlfe)\
**Post date:** [June 18, 2021, 2:20pm UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/3 "2021-06-18T14:20:18Z")

</div>

Thanks for the reply! I should have mentioned, setTimeout() isn’t available in Airtable scripting so that’s part of why I’m looking for other methods

Maybe if I can create my own timeout another way

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [June 18, 2021, 2:55pm UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/4 "2021-06-18T14:55:46Z")

</div>

> [@alxwlfe](#):
>
> setTimeout() isn’t available in Airtable scripting

If so, then I can only suggest you change to something else, since that’s a major flaw!  
And also wondering, why you are paying for airtable, since it looks like plain free node.js?

And when said, their community could help better, since they know their API, like this post:

> **[I need a DELAY method & setTimeout() is undefined (not found Window)](https://community.airtable.com/t5/development-apis/i-need-a-delay-method-settimeout-is-undefined-not-found-window/td-p/47501)**
>
> Hey, I’m a newbie with JavaScript so this might be obvious … I need a delay(ms) method to slow down the script after 5 API calls (limit 5/min.). Problem is all the JavaScript help on the intertube points to the setTimeout() method of the Window...

---

<div class="post-metadata">

**Author:** ![alxwlfe](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/alxwlfe/32/243388_2.png) [@alxwlfe](https://forums.plex.tv/u/alxwlfe)\
**Post date:** [June 18, 2021, 3:34pm UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/5 "2021-06-18T15:34:45Z")

</div>

Gotcha, yeah, ideally it’d be great if I could bake the timeout into the `fetch()` request to Plex itself, but other data I’m working with lives in Airtable, and they handle the environment/hosting, so as someone newer to JS it’s convenient

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![alxwlfe](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/alxwlfe/32/243388_2.png) [@alxwlfe](https://forums.plex.tv/u/alxwlfe)\
**Post date:** [September 29, 2021, 3:38pm UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/6 "2021-09-29T15:38:00Z")

</div>

Okay posting here again to see if perhaps there’s another way - anyone found a simple fetch() or other API request to just ping/check if the IP/port is online?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [September 29, 2021, 4:55pm UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/7 "2021-09-29T16:55:55Z")

</div>

> [@alxwlfe](#):
>
> anyone found a simple fetch() or other API request to just ping/check if the IP/port is online

Issue a get towards http(s)://PMS\_Server:32400/identity

---

<div class="post-metadata">

**Author:** ![alxwlfe](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/alxwlfe/32/243388_2.png) [@alxwlfe](https://forums.plex.tv/u/alxwlfe)\
**Post date:** [September 30, 2021, 1:04am UTC](https://forums.plex.tv/t/help-with-api-fetch-requests-never-ending-when-server-offline/723212/8 "2021-09-30T01:04:58Z")

</div>

thanks, unfortunately that (and various iterations I tried) didn’t work but I’ll keep banging my head against this one 😅
