Back

[SOLVED] TypeError: userFunction is not a function

  • 1
  • Self Hosted
  • Functions
  • General
Vertigo
5 Jul, 2024, 12:31

Hello everyone, I have created a server function with all possible Node.js versions and successfully deployed it in my local Docker instance. I deployed it either via the CLI or manually. However, when executing, I always get the error: TypeError: userFunction is not a function.

Please help

TL;DR
Issue: Developers were encountering a TypeError when deploying their function on Appwrite, specifically related to creating documents in batches. Solution: The error was due to the function firing create documents simultaneously. Restructuring the code to batch create documents 100 at a time resolved the issue. Additionally, developers were advised to check the Appwrite docs for functions development and verify the entry point in the function code.
CodingXeer01
6 Jul, 2024, 04:08

This seems to be an error in your code.

CodingXeer01
6 Jul, 2024, 04:09
Vertigo
6 Jul, 2024, 07:58

Well the code runs successfully locally. It fails, when i deploy it and execute it in appwrite.I

darShan
6 Jul, 2024, 13:35

Can you show the entrypoint of the function? Also the local appwrite version and the self hosted one.

Vertigo
6 Jul, 2024, 17:47
Vertigo
6 Jul, 2024, 17:47

the local appwrite version is 1.5.7

Vertigo
6 Jul, 2024, 17:48

the self hosted one is also the 1.5.7 version

darShan
7 Jul, 2024, 07:51

i meant the entrypoint in the function code.

Vertigo
7 Jul, 2024, 14:03

of course this is the code of the main.js

Steven
7 Jul, 2024, 15:18

This is not a valid Appwrite function. Please read the docs: https://appwrite.io/docs/products/functions/develop

Vertigo
7 Jul, 2024, 16:36

Thanks Steven, i restructured my function, but i have an problem with bulk creating documents. I know that this topic was mentioned here in discord and github, but i wonder if there is reliable solution in appwrite itself

here is my actual code of my last etl process I have seen your comment on github, but i cannot find your suggested solution

https://github.com/appwrite/appwrite/issues/4820#issuecomment-1339983075

Steven
7 Jul, 2024, 16:42

This fires all the create documents at the same time. It would be best to batch them 100 at a time or so

Vertigo
7 Jul, 2024, 17:06

Ok i understand. I sliced the incoming array into smaller batches, but now it threw this Error.

Error creating batch 1: TypeError: fetch failed at node:internal/deps/undici/undici:12500:13 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async _Client.call (file:///usr/local/server/src/function/node_modules/node-appwrite/dist/client.mjs:263:22) at async Databases.createDocument (file:///usr/local/server/src/function/node_modules/node-appwrite/dist/services/databases.mjs:1624:12) at async Promise.all (index 0) at async loadData (file:///usr/local/server/src/function/src/etl/loadings/loadClickupData.js:32:7) at async Module.default (file:///usr/local/server/src/function/src/main.js:36:5) at async execute (/usr/local/server/src/server.js:157:22) at async action (/usr/local/server/src/server.js:174:13) at async /usr/local/server/src/server.js:10:9 { [cause]: AggregateError [ECONNREFUSED]: at internalConnectMultiple (node:net:1116:18) at afterConnectMultiple (node:net:1683:7) { code: 'ECONNREFUSED', [errors]: [ [Error], [Error] ] } } Error creating batch 2: TypeError: fetch failed

Steven
7 Jul, 2024, 18:13

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

Steven
7 Jul, 2024, 18:14

What did you put for your Appwrite endpoint?

Vertigo
14 Jul, 2024, 03:10

Yeah this was an endpoint problem as mentioned in my other thread. You can close this thread too and marked as solved 😉 i changed the env variables and the endpoint to my local lan ip

Steven
18 Jul, 2024, 00:00

[SOLVED] TypeError: userFunction is not a function

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more