Back

how to debug appwrite function locally?

  • 2
  • Functions
  • Cloud
ropi95
2 Jan, 2024, 16:07

Yes correct,

TL;DR
The user is asking how to debug an appwrite function locally. They are provided with a link to a GitHub repository and are told to spin up the correct open-runtimes container to build exactly like Appwrite would. They mention some problems with BUN and suggest using other runtimes. The user is given instructions on how to debug code using breakpoints and exporting functionality. They are also advised to test the function through Postman. Debugging locally without deploying to a server is discussed. The user expresses a desire to test from Postman. The solution provided is to push the function to Appwrite and run it there, as it is simple
ropi95
2 Jan, 2024, 16:07

I want to test it from postman

ropi95
2 Jan, 2024, 16:07

Without deploy to server

ropi95
2 Jan, 2024, 16:07

And debug locally

ideclon
2 Jan, 2024, 16:08

Honestly, I usually just push my Function to Appwrite and run, then fix and push again, etc. Pushing Functions to Appwrite is so simple and fast that I don’t really see the point in attempting to run outside Appwrite, where you won’t be in exactly the same environment you’ll be in in production.

ideclon
2 Jan, 2024, 16:12

If you do really want to run the Functions locally, I can explain how to - what runtime?

Runpace
2 Jan, 2024, 17:01

I think you are not able to test it via postman without deploying at least not that easy, yet you can basically remove context from your function and run it like normal script and add your own debug logs instead of context logs.

ideclon
2 Jan, 2024, 18:05

It is possible, just probably unnecessarily complicated

erikkamalov
2 Jan, 2024, 18:43

@ropi95 It's pretty easy, you can run any runtime server and export your functionality.

erikkamalov
2 Jan, 2024, 18:44

Then you can test your function through postman.

ideclon
2 Jan, 2024, 18:48

Sorry, could you please explain what you mean by this?

erikkamalov
2 Jan, 2024, 18:50

It's the middle of the night right now, tomorrow morning I'll do an approximate project and show you.

ideclon
2 Jan, 2024, 18:50

Just wondering what you mean by “run a runtime server”

ideclon
2 Jan, 2024, 18:51

And “export your functionality”

erikkamalov
3 Jan, 2024, 04:36

@ideclon @ropi95 @Runpace it may be useful to you https://github.com/ekamalov/bun-debug.git

you can debug your code, use breakpoints.

erikkamalov
3 Jan, 2024, 04:37

open via vscode, run code

erikkamalov
3 Jan, 2024, 04:38

don't forget to add header x-open-runtimes-secret

erikkamalov
3 Jan, 2024, 04:39

this fully meets the requirements of the runtime

erikkamalov
3 Jan, 2024, 04:40

but I'm seeing some problems with the BUN, you can use other runtimes.

erikkamalov
3 Jan, 2024, 04:41
erikkamalov
3 Jan, 2024, 04:44

breakpoint

ideclon
3 Jan, 2024, 05:07

I don’t see where you’re exposing a web server here?

erikkamalov
3 Jan, 2024, 08:03

sorry check now, i added server

erikkamalov
3 Jan, 2024, 08:03
ideclon
3 Jan, 2024, 18:20

You got that from here, right?

But while this would be ok for basic debugging, you’re still not in the same environment you’ll be in when you ultimately deploy to Appwrite. If you’re going to do this locally, I’d say it would be better to spin up the correct open-runtimes container, and build exactly like Appwrite would.

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