Skip to content

A call to a function run two full task lifecycles at the same position #1859

Done

Description

@mathecruz

Summary

When a call task points to a function, the runtime runs two complete task lifecycles on the same position: one for the calling task and one for the function body. The function itself runs only once (one HTTP request), but every lifecycle side effect happens twice.

Reproducer

If you want to run the application clone the following repository https://github.com/mathecruz/owscloud

document:
  dsl: 1.0.3
  namespace: default
  name: dynamodb-put-item
  version: 0.1.0
use:
  functions:
    aws-dynamodb-putitem:
      call: http
      with:
        method: post
        endpoint: http://localhost:4566/
        headers:
          Content-Type: application/x-amz-json-1.0
          X-Amz-Target: DynamoDB_20120810.PutItem
        body: "${ . }"
do:
- SaveParent:
    try:
    - Save:
        output:
          as: "${ $task.rawInput }"
        call: aws-dynamodb-putitem
        with:
          TableName: orders
          Item:
            id:
              S: "${ .id }"
            total:
              "N": "${ .total }"
    catch:
      errors:
        with:
          type: https://asl2ows.invalid/errors/DynamoDB.ProvisionedThroughputExceededException
      as: error
      retry:
        delay: PT0.5S
        backoff:
          exponential: {}
        limit:
          attempt:
            count: 3

Observed (execution trace listener)

Workflow name=dynamodb-put-item instanceId=01M7VDNVVR8P0NFH86CM29SH4A started input={"total":"42.50","id":"order-1001"}
Task 'SaveParent' started  pos=do/0/SaveParent/try
Task 'Save'       started  pos=do/0/SaveParent/try/0/Save      <-- caller
Task 'Save'       started  pos=do/0/SaveParent/try/0/Save      <-- function body, same position
Request:  POST http://localhost:4566/  X-Flow-Task-Id=do/0/SaveParent/try/0/Save
          {"TableName":"orders","Item":{"id":{"S":"order-1001"},"total":{"N":"42.50"}}}
Response: 200 OK  {}
Task 'Save'       completed output={}                                   <-- function body: raw output
Task 'Save'       completed output={"total":"42.50","id":"order-1001"}  <-- caller: after output.as
Task 'SaveParent' completed output={"total":"42.50","id":"order-1001"}
Workflow ... completed

Expected

Task 'SaveParent' started
Task 'Save'       started   pos=do/0/SaveParent/try/0/Save
Request / Response (once)
Task 'Save'       completed output={"total":"42.50","id":"order-1001"}
Task 'SaveParent' completed output={"total":"42.50","id":"order-1001"}

This is what the same workflow produces when Save declares call: http inline instead of calling the function.

We can have problems with persistence, metrics and duplicated lifecycles.

Activity

  1. self-assigned this
    on Nov 21, 2026
  2. mathecruz commented on Nov 22, 2026

    @mathecruz
    CollaboratorAuthor

    @fjtirado My question is: should the function invoked by a call have its own lifecycle, or should only the call task have one, with the function body emitting no events and creating no persistence checkpoint of its own?

  3. self-assigned this
    on Nov 23, 2026
  4. fjtirado commented on Nov 23, 2026

    @fjtirado
    Collaborator

    @mathecruz There should be two life cycly event, one for the function call and another for the actual function.
    Rationale is that both have different input and output (as it is clear in your examples.
    What need to be modified if the positiokn of the actual function call. In the example, aws-dynamodb-putitem should be added to the position
    Ill file a PR

  5. added 7 commits that reference this issue on Nov 23, 2026
    f74b138
    4177c54
    0d0cb79
    53f0b55
    e87f384
    e691383
    6da83a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions