Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Node SDK Fetch Fail Issues #8311

Open
2 tasks done
ItzNotABug opened this issue Jun 23, 2024 · 6 comments
Open
2 tasks done

🐛 Bug Report: Node SDK Fetch Fail Issues #8311

ItzNotABug opened this issue Jun 23, 2024 · 6 comments
Assignees
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@ItzNotABug
Copy link
Contributor

ItzNotABug commented Jun 23, 2024

👟 Reproduction steps

When using a batch process like below (or even listDocuments) in a Function, Node SDK often fails with timeouts and fetch failed -

// exact 60 items in here.
for (const [index, randomId] of randomIds.entries()) {
  try {
      const document = await databases.getDocument(
          databaseId,
          collectionId,
          randomId.toString(),
      );

      await updateDocument(document, index);
  } catch (error) {
      console.error(`Index: ${index + 1}, Identifier: ${randomId}, ${error}`);
  }
}

Error Cause -

{"error":{"cause":{"code":"ETIMEDOUT"}}}

The same is pretty usable on Dart SDK (only tested this) and on local executions.
Sometimes a logic like sleep/delay is helpful but not always & is really not optimal as it can take upto minutes to update the documents where using something like Promise.all is pretty much under 10s.

👍 Expected behavior

No timeouts.

👎 Actual Behavior

Timeouts.

🎲 Appwrite version

Version 1.5.x

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@ItzNotABug ItzNotABug added the bug Something isn't working label Jun 23, 2024
@ItzNotABug ItzNotABug changed the title 🐛 Bug Report: Node SDK Fetch Fails Issues 🐛 Bug Report: Node SDK Fetch Fail Issues Jun 23, 2024
@ItzNotABug
Copy link
Contributor Author

Update: I've found the cause for this which might be coming from Node:20+ Runtime.
I tested the same logic on Node:18, Node:19 and the same worked fine.

The problem seems to be coming from DNS logic that was changed on Node:20+ I think. I say this because I used a custom domain for the Server SDK Endpoint which was proxied through Cloudflare and that caused an issue.


Node:20 Specific Tests:

  1. Main Domain => Pass
  2. CNAME Domain With Cloudflare Proxy On => Fail
  3. CNAME Domain Without Cloudflare Proxy On => Pass

Runtimes:

  1. Node: 18 => Pass
  2. Node: 19 => Pass
  3. Node: 20 => Timeout Errors

@stnguyen90
Copy link
Contributor

@ItzNotABug, whoa! Can you reproduce this with just node (specific version in the runtime) and not in an Appwrite Function?

@stnguyen90 stnguyen90 added the product / functions Fixes and upgrades for the Appwrite Functions. label Jun 27, 2024
@stnguyen90 stnguyen90 self-assigned this Jun 27, 2024
@ItzNotABug
Copy link
Contributor Author

ItzNotABug commented Jun 27, 2024

@ItzNotABug, whoa! Can you reproduce this with just node (specific version in the runtime) and not in an Appwrite Function?

I've tested on a self hosted instance with Functions. Usage via Server Side SDK on a local machine works fine. Its just the function runtime acting out.

Alternatively, I tested with Dart Server SDK on Functions, that went fine.

I could share a video of the issue.

@ItzNotABug
Copy link
Contributor Author

Update 2: I somehow also managed to get this on a local execution (via a node misc.js).

Trace -

TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11372:11)
at process.processTicksAndRejections (node: internal/process/task_queues:95:5)
at async _Client.call (file:https:///Users/itznotabug/ProjectName/node_modules/node-appwrite/dist/client.mjs:263:22)
at async Messaging.createSubscriber (file:https:///Users/itznotabug/ProjectName/node_modules/node-appwrite/dist/services/messaging.mjs:2083:12)
at async file:https:///Users/itznotabug/ProjectName/misc.js:17:17
at async Promise.all (index 277)
at async processUsers (file:https:///Users/itznotabug/ProjectName/misc.js:30:21)
at async file:https:///Users/itznotabug/ProjectName/misc.js:50:1

Node: v20.9.0

@stnguyen90
Copy link
Contributor

@ItzNotABug, nice! Looks like you've narrowed down the problem to v20.9.0. Does it occur in the latest v20?

@ItzNotABug
Copy link
Contributor Author

ItzNotABug commented Jul 1, 2024

@stnguyen90, I haven't tested this on a Node:21 but I see that the functions use FROM node:20.11-alpine3.19 so the error happens there too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

2 participants