fauna / faunadb-js

Javascript driver for Fauna v4 (deprecated)
https://docs.fauna.com/fauna/v4/
Other
702 stars 75 forks source link

Failing Queries from Cancelled Stream Error #648

Closed BobbyRadford closed 2 years ago

BobbyRadford commented 2 years ago

I am getting the following error message from the FaunaDB driver version 4.6.0. I am processing a large list of user data and making several calls to Fauna to check for existence and then creating or updating accordingly. There are a few other DB queries associated with this, but that's the gist of it.

This error comes sporadically at some point during the data processing. It doesn't happen at the same place in the list each time. Could this be related to rate-limiting or anything of the sort? This seems to happen more quickly if I run the processing by handling users in parallel. It's a bit odd that this looks like a DNS problem, but plenty of queries succeed prior to the failure.

Error

Error: The pending stream has been canceled (caused by: getaddrinfo ENOTFOUND db.fauna.com)

Stack

[1658259301914] ERROR (17003 on MacBook-Pro.local): DB query failed: {"cause":{"errno":-3008,"code":"ENOTFOUND","syscall":"getaddrinfo","hostname":"db.fauna.com"},"code":"ERR_HTTP2_STREAM_CANCEL"}
    txn: "ZLEuTsQb"
[1658259301914] DEBUG (17003 on MacBook-Pro.local): Query duration: 21ms
    txn: "ZLEuTsQb"
[1658259301914] ERROR (17003 on MacBook-Pro.local): Failed to import users: 'Error: The pending stream has been canceled (caused by: getaddrinfo ENOTFOUND db.fauna.com)
    at new NodeError (node:internal/errors:372:5)
    at closeSession (node:internal/http2/core:1136:20)
    at ClientHttp2Session.destroy (node:internal/http2/core:1530:5)
    at TLSSocket.socketOnError (node:internal/http2/core:2981:13)
    at TLSSocket.emit (node:events:527:28)
    at TLSSocket.emit (node:domain:475:12)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)'

Software Versions

github-actions[bot] commented 2 years ago

Internal ticket number is FE-2500

faunaee commented 2 years ago

(caused by: getaddrinfo ENOTFOUND db.fauna.com)

That error indicates that your application's DNS resolver is unable to locate the IP address for db.fauna.com. There's nothing the driver can do about this problem: you have to fix it in your DNS infrastructure.

That the error is intermittent might be an indication that your DNS resolver is not caching results, or is suffering intermittent outages itself.

BobbyRadford commented 2 years ago

Hey, thanks for the reply @faunaee. That very well may be the case. It's odd that this seems to only happen when processing records in parallel. For some reason, this highlights some underlying brittleness in the DNS. I don't know if this is specific to Node, the underlying OS system calls, or network infrastructure in general.

The way I got around this was to surround the important client queries with retry logic. The problem is sporratic enough that retrying usually works. Not saying that's my favorite solution, but it seems to work.

macnealefauna commented 2 years ago

@BobbyRadford - is there code you are willing to share to reproduce this?

cleve-fauna commented 2 years ago

Hey @BobbyRadford please reopen if you would like further assistance.