# NodeJS scripts timeout

**URL:** <https://forum.dfinity.org/t/nodejs-scripts-timeout/18490>\
**Category:** Developers\
**Created:** [February 15, 2023, 5:17am UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490 "2023-02-15T05:17:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 15, 2023, 5:17am UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/1 "2023-02-15T05:17:45Z")

</div>

Since a couple of days I often face timeout when I run my NodeJS command lines that interacts with the IC on mainnet but I’m not sure if it’s something on my hand (NodeJS version, Macos, network etc.) or if something on the IC side.

Has anyone else being to face recently timeout in his/her scripts?

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 15, 2023, 6:52pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/2 "2023-02-15T18:52:41Z")

</div>

Sound like a network issue. I was in the office today, stayed there after work to developed few stuffs and had no issue. Just went home and timeout happened again, so restarted my router, let’s see.

![Have You Tried Turning It Off And On Again GIFs | Tenor](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/8/82d68e597b5a1471e0bcffa1afd8ff1c2fd0a1e8.gif)

---

<div class="post-metadata">

**Author:** ![rckprtr](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rckprtr/32/809_2.png) [@rckprtr](https://forum.dfinity.org/u/rckprtr)\
**Post date:** [February 16, 2023, 12:28am UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/3 "2023-02-16T00:28:09Z")

</div>

Let me know the results please! I have had the same issue for a couple weeks and I just use my VPN with no issues.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 16, 2023, 5:23am UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/4 "2023-02-16T05:23:45Z")

</div>

Yesterday evening after restart it seemed more stable. However at some point I noticed again a new timeout. I’ll keep monitoring and let you know.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 16, 2023, 1:50pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/5 "2023-02-16T13:50:59Z")

</div>

Alright so same issue happened in middle of a recorded video, loved it 😂.

Definitely something fishy elsewhere than on my network.

---

<div class="post-metadata">

**Author:** ![rckprtr](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rckprtr/32/809_2.png) [@rckprtr](https://forum.dfinity.org/u/rckprtr)\
**Post date:** [February 16, 2023, 3:03pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/6 "2023-02-16T15:03:54Z")

</div>

There is a twitter thread that is growing about a similar error that has gone out.

I can reproduce it 100% of the time without a VPN.

`FetchError: request to https://ic0.app/api/v2/canister/zfcdd-tqaaa-aaaaq-aaaga-cai/query failed, reason: connect ETIMEDOUT`

This is the error from my typescript client above. I do not see this error from the browser.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 16, 2023, 3:50pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/7 "2023-02-16T15:50:46Z")

</div>

Do you have the link the twitter thread?

I’ll then share the issue with the team internally (since I’m not the only weirdo NodeJS guy who face it 😉)

---

<div class="post-metadata">

**Author:** ![rckprtr](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rckprtr/32/809_2.png) [@rckprtr](https://forum.dfinity.org/u/rckprtr)\
**Post date:** [February 16, 2023, 6:20pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/8 "2023-02-16T18:20:15Z")

</div>

> <https://twitter.com/dgdg_app/status/1626036855887077376>

---

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [February 16, 2023, 6:40pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/9 "2023-02-16T18:40:36Z")

</div>

I believe this is an issue between how fetch is implemented in Node 16 vs. Node 18. I ran into this issue when beta testing some IC software, and ran into similar issues originally when developing the CanDB frontend client sdk. It might be this plus a combination older version of the sdk being run that is expecting a particular node version?

Try downgrading from Node 18 to Node 16 and let me know if the issue still persists.

Also, what version of node are you currently using?

---

<div class="post-metadata">

**Author:** ![mbeekman](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mbeekman/32/2675_2.png) [@mbeekman](https://forum.dfinity.org/u/mbeekman)\
**Post date:** [February 16, 2023, 7:27pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/10 "2023-02-16T19:27:09Z")

</div>

Hello Everyone … @icme is right, Node 16 seems happy, Node 18.14, not so happy … intermittent timeouts … usually in succession … fail fail fail fail, success, success, success, fail fail … etc … just confirmed latest @dfinity npm packages 0.15.3 …

```auto

Error in checkTokenResponse: ICPM Error: FetchError: request to https://ic0.app/api/v2/canister/5zc2i-mqaaa-aaaal-abcoa-cai/read_state failed, reason: connect ETIMEDOUT 2600:c00:2:100:5000:d0ff:fe62:c29b:443

Error in checkTokenResponse: ICPM Error: FetchError: request to https://ic0.app/api/v2/canister/5zc2i-mqaaa-aaaal-abcoa-cai/call failed, reason: connect ETIMEDOUT 2600:c00:2:100:5000:d0ff:fe62:c29b:443

```

notice too that the endpoints are different … @rckprtr 's was a ‘/query’ and this shows ‘/call’ and ‘/read\_state’ … makes it seem like @icme said that it may be the new implementation of fetch … an api issue at the boundary?

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 16, 2023, 8:43pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/11 "2023-02-16T20:43:53Z")

</div>

I remember having tried to downgrade to v16 and still faced the issue but maybe my test wasn’t accurate (was an evening late…)

@anon74414410 have you faced such an issue and maybe an idea?

---

<div class="post-metadata">

**Author:** ![mbeekman](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mbeekman/32/2675_2.png) [@mbeekman](https://forum.dfinity.org/u/mbeekman)\
**Post date:** [February 16, 2023, 9:04pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/12 "2023-02-16T21:04:44Z")

</div>

And today is the first we have had such an issue on my end … not sure if it matters … @icme and I are in California … and I have a colleague in NY who has 0 issues with either 16 or 18 … maybe certain boundary nodes? … just guessing …

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 16, 2023, 9:30pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/13 "2023-02-16T21:30:31Z")

</div>

Thanks for the input. On my way home, late evening here but, will ping the BN team when I get there to forward the info

(update: done, msg forwarded)

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [February 16, 2023, 10:25pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/14 "2023-02-16T22:25:16Z")

</div>

I’ve never encountered ETIMEDOUT, personally, but I do less application development than you

---

<div class="post-metadata">

**Author:** ![rckprtr](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rckprtr/32/809_2.png) [@rckprtr](https://forum.dfinity.org/u/rckprtr)\
**Post date:** [February 17, 2023, 5:49am UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/15 "2023-02-17T05:49:38Z")

</div>

Issue cleared up on my side: Node 18 with npm dfx 15

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 17, 2023, 6:02am UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/16 "2023-02-17T06:02:34Z")

</div>

> [@rckprtr](#):
>
> with npm dfx 15

npm dfx 15? 🤔

npm v8 and dfx v0.13.1?

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 17, 2023, 4:35pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/17 "2023-02-17T16:35:23Z")

</div>

Regardless of the NodeJS version go the error. I’ve forwarded following stacktrace and sample repo to reproduce the issue.

```auto
❯ npm run start

> @junobuild/example-node@0.0.1 start
> node index.mjs

This is a demo client in NodeJS
file:///Users/daviddalbusco/projects/juno/examples/node/node_modules/node-fetch/src/index.js:108
			reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, 'system', error));
			       ^

FetchError: request to https://ic0.app/api/v2/canister/xo2hm-lqaaa-aaaal-ab3oa-cai/query failed, reason: connect ETIMEDOUT 2a0b:21c0:4003:2:5000:55ff:feb8:5f89:443
    at ClientRequest.<anonymous> (file:///Users/daviddalbusco/projects/juno/examples/node/node_modules/node-fetch/src/index.js:108:11)
    at ClientRequest.emit (node:events:525:35)
    at TLSSocket.socketErrorListener (node:_http_client:494:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  type: 'system',
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  erroredSysCall: 'connect'
}

Node.js v18.12.1

```

sample:

```auto
git clone https://github.com/buildwithjuno/examples
cd examples/node
npm ci
npm run start

```

---

<div class="post-metadata">

**Author:** ![mbeekman](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mbeekman/32/2675_2.png) [@mbeekman](https://forum.dfinity.org/u/mbeekman)\
**Post date:** [February 17, 2023, 5:02pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/18 "2023-02-17T17:02:25Z")

</div>

not sure if it helps, but this issue persists today, and intermittent as of the last few days and is a mainnet conversation …

```auto
FetchError: request to https://ic0.app/api/v2/canister/5zc2i-mqaaa-aaaal-abcoa-cai/call failed, reason: connect ETIMEDOUT 2600:c00:2:100:5000:d0ff:fe62:c29b:443

```

first try times out and second try it works …

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [February 17, 2023, 5:17pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/19 "2023-02-17T17:17:58Z")

</div>

> [@mbeekman](#):
>
> `FetchError: request to https://ic0.app/api/v2/canister/5zc2i-mqaaa-aaaal-abcoa-cai/call failed, reason: connect ETIMEDOUT 2600:c00:2:100:5000:d0ff:fe62:c29b:443`

thanks, I’ll share that error too

---

<div class="post-metadata">

**Author:** ![theloniousiiVI](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/theloniousiivi/32/2679_2.png) [@theloniousiiVI](https://forum.dfinity.org/u/theloniousiiVI)\
**Post date:** [February 17, 2023, 6:44pm UTC](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490/20 "2023-02-17T18:44:56Z")

</div>

![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/9/90a68505fa0ebeda63a11d2928eb37d643389a5a.png)

Following this as well, in US on the east coast, unable to duplicate the network timeout issues from here.

Peter, my run of your test seems happy with all flavors Node 18+. Have verified with 18.14/LTS, 18.13 (previous LTS), and 18.12.1 (the version in your example).

I’ve incurred no blips at all on repeated tries with all the above. We just don’t seem to having boundary/API quirks as you’re seeing farther west.

Node 16 does fail for me, but it seems like a different issue … undefined ‘Headers’ on invocation of your get() method(??)

Thanks Peter

[Next page](https://forum.dfinity.org/t/nodejs-scripts-timeout/18490.md?page=2)
