Back

Delayed function does not retain the function's body

  • 0
  • Functions
  • Flutter
  • Cloud
Samuel Kings
5 Sep, 2024, 22:34

I have a function executed like this

TypeScript
Map<String, dynamic> data = {
        "followerId": state.user!.$id,
        "followerName": state.profile!.name,
        "followerUserName": state.profile!.username,
        "followeeId": otherUserId
      };
String body = jsonEncode(data);

await functions.createExecution(
        functionId: appwriteConsts.functions.onFollowUser,
        body: body,
        xasync: true,
        scheduledAt: scheduleFor.toUtc().toIso8601String(),
      );

Upon execution, checking my Appwrite Cloud console, I see that the body is not there? Is this a bug, an unimplemented feature or there's something I'm not doing well?

TL;DR
Developers are discussing an issue where the delayed function is not retaining its body. The bug has been reproduced, and a fix is being worked on to ensure this doesn't happen again. The issue seems to be with scheduling the execution document correctly. More investigation is ongoing.
Samuel Kings
5 Sep, 2024, 22:56

Anyone here?

Samuel Kings
5 Sep, 2024, 22:58

I have the same result when I try to execute the same function from the console

darShan
6 Sep, 2024, 11:19

looking through the source, there is a good possibility that the body is not sent. let me confirm this from my side.

Samuel Kings
6 Sep, 2024, 11:20

Why does that happen?

darShan
6 Sep, 2024, 11:20

I am yet to confirm this, but if it indeed isn't sending the body, it was mostly a mistake.

Samuel Kings
6 Sep, 2024, 11:21

Alright. I'll be awaiting the result of your confirmation

darShan
6 Sep, 2024, 12:23

@Meldiron I don't think we are setting the body to scheduled executions. I did a print_r($schedule) in the ScheduleExecutions, the data is missing. Pretty sure we should be sending the body to the scheduler.

darShan
6 Sep, 2024, 12:25

It should be available in the schedules collection document iirc.

Meldiron
6 Sep, 2024, 13:05

Execution document is not supposed to have the body, and schedule document yes. Checking the logic here: https://github.com/appwrite/appwrite/blob/c58fa78962a1356d5dec11de326dc011bda59357/app/controllers/api/functions.php#L1934 All seems as intended. Ill try to quickly reproduce the bug now

darShan
6 Sep, 2024, 13:08

yupp, data is saved successfully. probably just not sent to the scheduler. or is this wrong?

TypeScript
$schedule['data']['*']

the doc doesn't seem to contain the data object at all. I couldn't see atleast.

darShan
6 Sep, 2024, 13:09

@Meldiron we probably just need below in $getSchedule?

TypeScript
'data' => $schedule->getAttribute('data'),
Meldiron
6 Sep, 2024, 13:11

Sounds correct. Ill reach out to Christy to see why it was not there in the first place, maybe it was intentional for other type of schedules

darShan
6 Sep, 2024, 13:12

possibly yep. we could do a check though. but lets wait for christy

Meldiron
6 Sep, 2024, 13:12

@Samuel Kings good news, I managed to reproduce it and @darShan 's bug suspicison seems very correct. Ill work on a fix, and also ensure the behaviour with a newly added test to make sure this never happens again.

darShan
6 Sep, 2024, 13:13

also, the keys wouldn't make sense if the schedule is after 15 mins no?

Meldiron
6 Sep, 2024, 13:14

You mean dynamic API keys? Those are only generated on function's worker, so right before execution (just when scheduledAt hits)

darShan
6 Sep, 2024, 13:15
  1. nope, i issued a scheduled function to execute after 2 hours, i see - x-appwrite-key in the recd. scheduled doc.
  2. also jwt
darShan
6 Sep, 2024, 13:16

let me ping you with more details. this discussion is just blocking the thread.

Samuel Kings
6 Sep, 2024, 13:29

Alright. Glad to hear this ☺️ Thanks guys

Samuel Kings
6 Sep, 2024, 16:04

Please when can we expect a fix?

Meldiron
6 Sep, 2024, 16:05

Friday releases are always scarry, so you can expect a fix next week. Ill keep this at the top of my todo list, to make sure it's finished asap, and Ill propose deployment the same day

Samuel Kings
6 Sep, 2024, 16:09

Alright then. Thanks

Samuel Kings
12 Sep, 2024, 08:43

Hi @Meldiron Please what is the status of this?

darShan
12 Sep, 2024, 09:00

A PR has been created and validated, but since the team is away rn, you can expect the fix landing around early next week, possibly sooner too.

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