Skip to content

StepFunctions: Promise.all(array.map) should be parallel #481

@sam-goodwin

Description

@sam-goodwin

The following common pattern os using Promise.all and array.map(Promise) does not use a Parallel state. It should.

Doing this generally would be difficult (maybe impossible) without type information. Perhaps we can implement a heuristic to detect this pattern.

new StepFunction(
  stack,
  "SendMessageBatch",
  async (input: { messages: OrderPlacedEvent[] }) => {
    await Promise.all(
      input.messages.map(async (message) => {
        await orderQueue.sendMessage({
          MessageBody: message,
        });
      })
    );
  }
);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions