fix: patch node-fetch-native-with-agent to bypass bundled undici on Node 26

node-appwrite 23.1.0 ships a bundled undici Agent via node-fetch-native-with-agent.
That bundle uses an older undici dispatcher API that crashes on Node 26 with
'invalid onError method' (UND_ERR_INVALID_ARG), making every Appwrite call
fail with 'fetch failed' / our user-facing 'Bağlantı hatası' fallback.

The patch replaces createAgent/createFetch with thin pass-throughs to
globalThis.fetch — Node native fetch handles HTTPS to db.kovaksoft.com
directly, no proxy/agent customization needed. Verified end-to-end via
users.listMemberships against the live project.

Also added dev-mode error surfacing in appwriteError so future SDK
exceptions show the real message instead of 'Bağlantı hatası'.
This commit is contained in:
kovakmedya
2026-05-21 19:31:16 +03:00
parent 1dd8627c30
commit 9ea35e88cf
4 changed files with 45 additions and 2 deletions
+4
View File
@@ -27,6 +27,9 @@ function appwriteError(e: unknown): string {
return e.message || "Beklenmeyen bir hata oluştu.";
}
}
if (process.env.NODE_ENV !== "production" && e instanceof Error) {
return `Bağlantı hatası: ${e.message}`;
}
return "Bağlantı hatası. Tekrar deneyin.";
}
@@ -90,6 +93,7 @@ export async function signInAction(_prev: AuthState, formData: FormData): Promis
sessionId = session.$id;
await setSessionCookie(session.secret, session.expire);
} catch (e) {
console.error("[signInAction] createEmailPasswordSession", e);
return { ok: false, error: appwriteError(e) };
}