Skip to main content
May 4, 2026
Solved

App builder action is returning 504 Gateway

  • May 4, 2026
  • 2 replies
  • 68 views

When invoking a long-running action with --result, the CLI returns a 504 Gateway Timeout after ~60 seconds — even though the action continues running successfully in the background. 

 

However, the unexpected behavior is that the CLI appears to automatically retry the invocation after each 504, resulting in multiple activations being created from a single invoke command. In my case, one command produced 3 concurrent activations all processing the same dataset simultaneously.

 

How can this issue be resolved ? 

Best answer by Meghana_N

Thanks for the response ​@manavluhar 

This was resolved by implementing the below steps :

Layer 1: Same-Container Guard

A module-level boolean flag is set to true when the action starts. If a second activation lands on the same warm container, it sees the flag and immediately returns 409 without doing any work.

Layer 2: Cross-Container Guard

At startup, each activation queries the OpenWhisk Activations API for any other completed activations of the same action in the last 25 minutes. If one is found, it returns 409 immediately.

Layer 1 alone misses activations on different containers. Layer 2 alone can't catch two activations starting simultaneously (neither has completed yet). Together they cover all practical scenarios. Both layers fail-open — if the OpenWhisk API check itself fails, the action proceeds rather than blocking all future runs.

2 replies

manav
Adobe Champion
Adobe Champion
May 4, 2026

Good one ​@Meghana_N, This is almost always caused by one of two things:

  • External API Latency: Your App Builder action is making an outbound network request to a third-party service [like an ERP, Adobe Commerce or external database]

    • That downstream service hangs, runs slowly, or fails to respond. Because there is no client-side timeout defined in your code, the App Builder action waits indefinitely until OpenWhisk forcibly kills the process at the 60-second mark, resulting in a 504. If you are using a library like node-fetch or axios inside your App Builder action, strictly define an outbound timeout and try.

  • Unresolved DNS Queries: The domain of the external service cannot be resolved, leaving the HTTP request hanging in a perpetual wait state. If the external service genuinely needs more than 60 seconds to process data such as importing a large massive catalog, you cannot perform this synchronously.

#MagentoMan
manav
Adobe Champion
Adobe Champion
May 5, 2026

@Meghana_N please do mark this reply as answer or solution, if your issue is fixed, thank you!

#MagentoMan
Meghana_NAuthorAccepted solution
May 5, 2026

Thanks for the response ​@manavluhar 

This was resolved by implementing the below steps :

Layer 1: Same-Container Guard

A module-level boolean flag is set to true when the action starts. If a second activation lands on the same warm container, it sees the flag and immediately returns 409 without doing any work.

Layer 2: Cross-Container Guard

At startup, each activation queries the OpenWhisk Activations API for any other completed activations of the same action in the last 25 minutes. If one is found, it returns 409 immediately.

Layer 1 alone misses activations on different containers. Layer 2 alone can't catch two activations starting simultaneously (neither has completed yet). Together they cover all practical scenarios. Both layers fail-open — if the OpenWhisk API check itself fails, the action proceeds rather than blocking all future runs.

manav
Adobe Champion
Adobe Champion
May 5, 2026

Good catch! Thanks for sharing it here

#MagentoMan