Back

[SOLVED] context.req.body is empty if set xasync=True

  • 0
  • Cloud
versun
22 Oct, 2023, 02:22

I add context.log(context.req.url) , and I get this url: http://65347da628372:3000/ I don't think this is a valid url It was working fine until 1.4.5 without any code changes, but after 1.4.6 this problem appeared

TL;DR
[SOLVED] The issue with `context.req.body` being empty when `xasync=True` has been fixed. The fix has been pushed to the cloud. If you're experiencing this issue, try not using `async`, and instead narrow down the data that needs to be processed within 30 seconds or less. This can lead to an increase in the number of function executions. Make sure to manually set the host in the header if needed.
RAKU
22 Oct, 2023, 05:35

Hi,

I am also facing the same issue. If we set async false then its working perfectly, but setting the async to true makes the body empty.

Please lemme know if you find any solution πŸ™‚

Translocator
22 Oct, 2023, 20:13

Same problem here. This issue, coupled with @Meldiron's update to disallow synchronous functions from running any longer than 30 seconds (as of 1.4.6), creates a pretty problematic double-whammy when you're making lengthy LLM calls 😬

Drake
22 Oct, 2023, 20:37

thanks everyone for chiming in! πŸ™πŸΌ

What runtimes are y'all using?

Translocator
22 Oct, 2023, 20:37

node 18.0 for me

Drake
22 Oct, 2023, 20:50

anyone able to create an issue for this?

Meldiron
23 Oct, 2023, 05:22

Hey there πŸ‘‹ How are you executing your function? Are you self-hosting, or using Appwrite Cloud?

Meldiron
23 Oct, 2023, 05:23

Hello πŸ‘‹ The hard-stop was added to executions over proxy (over function domain) in order to prevent API contaienrs rom getting frozen, considering they are thread-worker-style, not coroutine-style.

What is your use-case for long-running functions executed over custom domain? Would it be viable to create them as async executions instead?

versun
23 Oct, 2023, 06:20

I am using Appwrite Cloud. I am calling execution of another function in an scheduled execution function with the following code:

TypeScript
function.create_execution(
    rss_action_function, 
    path="/auto_update",
    method="POST",
    body=json.dumps({"o_docs": o_docs["documents"], "force":force}), 
    xasync=True
)

Also, I'm calling function on the front-end:

TypeScript
async function start_translate(payload,translation_process,translation_update) {
  functions.createExecution(Appwrite_Function, JSON.stringify(payload),true)
        .then(res => {
          //console.log(res);
          if (res.status != 'failed') {       
            translation_update.innerHTML += ' βœ”';
          }else{
            translation_update.innerHTML += ' ✘';
            console.error(res);
          }
          translation_process.style.display = 'none';
        });
}
Meldiron
23 Oct, 2023, 06:28

Seems like 65347da628372 could be hostname of container created for your function, and port 3000 being internal port for it's HTTP server.

Considering you dont provide custom host header, it's likely auto-filling it with closest it can guess from network request.

What behaviour would you expect for context.req.host?

Ajit Singh
23 Oct, 2023, 07:48

Same problrm with me too

Ajit Singh
23 Oct, 2023, 07:48

context.req.body context.req.body_raw are empty if I set async true

versun
23 Oct, 2023, 09:25

I just want get the body when async is true. So I need manual set the host in the header, right?

Ajit Singh
23 Oct, 2023, 09:36

Does not work already checked that

versun
23 Oct, 2023, 09:41

My solution now is: don't use async, then narrow down the data that needs to be processed and make sure it's done in 30 seconds or less!

However, this can lead to a large increase in the number of request function executions

Meldiron
23 Oct, 2023, 10:16

Oooh I missed the title. Yes, there seems to be something wrong with body for async executions. We are working on a fix.

Meldiron
23 Oct, 2023, 10:16

cc @Shimon

Drake
23 Oct, 2023, 22:29

@here, we've pushed a fix to cloud so this should be fixed now

versun
24 Oct, 2023, 01:46

It's working now. Thanks

versun
24 Oct, 2023, 01:47

[SOLVED] context.req.body is empty if set xasync=True

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