There is a strange DUPLICATE_STATE_NAME error when registering multiple state machines with similarly named steps, even though the state machines are named differently and should be completely independent.
[Serverless Step Functions Local] 2021-10-25 22:18:49.515: CreateStateMachine => {"requestClientOptions":{"readLimit":131073,"skipAppendUriPath":false},"requestMetricCollector":null,"customRequestHeaders":null,"customQueryParameters":null,"cloneSource":null,"sdkRequestTimeout":null,"sdkClientExecutionTimeout":null,"name":"ExampleStateMachine2","definition":"{\"Comment\":\"Example 2\",\"StartAt\":\"PassTask\",\"States\":{\"PassTask\":{\"Type\":\"Pass\",\"Next\":\"AnotherPassTask\"},\"AnotherPassTask\":{\"Type\":\"Pass\",\"End\":true}}}","roleArn":"arn:aws:iam::101010101010:role/DummyRole","type":null,"loggingConfiguration":null,"tags":null,"tracingConfiguration":null,"requestCredentials":null,"requestCredentialsProvider":null,"generalProgressListener":{"syncCallSafe":true},"readLimit":131073,"cloneRoot":null}
[Serverless Step Functions Local] 2021-10-25 22:18:49.515: CreateStateMachine => {"requestClientOptions":{"readLimit":131073,"skipAppendUriPath":false},"requestMetricCollector":null,"customRequestHeaders":null,"customQueryParameters":null,"cloneSource":null,"sdkRequestTimeout":null,"sdkClientExecutionTimeout":null,"name":"ExampleStateMachine1","definition":"{\"Comment\":\"Example 1\",\"StartAt\":\"PassTask\",\"States\":{\"PassTask\":{\"Type\":\"Pass\",\"Next\":\"AnotherPassTask\"},\"AnotherPassTask\":{\"Type\":\"Pass\",\"End\":true}}}","roleArn":"arn:aws:iam::101010101010:role/DummyRole","type":null,"loggingConfiguration":null,"tags":null,"tracingConfiguration":null,"requestCredentials":null,"requestCredentialsProvider":null,"generalProgressListener":{"syncCallSafe":true},"readLimit":131073,"cloneRoot":null}
Invalid Definition --------------------------------------
InvalidDefinition: Invalid State Machine Definition: ''DUPLICATE_STATE_NAME: Duplicate State name: PassTask at /States/PassTask', 'DUPLICATE_STATE_NAME: Duplicate State name: AnotherPassTask at /States/AnotherPassTask''
...
[Serverless Step Functions Local] 2021-10-25 22:23:10.847: [400] CreateStateMachine <= Invalid State Machine Definition: ''DUPLICATE_STATE_NAME: Duplicate State name: AnotherPassTask at /States/AnotherPassTask''
[Serverless Step Functions Local] 2021-10-25 22:23:10.849: [200] CreateStateMachine <= {"sdkResponseMetadata":null,"sdkHttpMetadata":null,"stateMachineArn":"arn:aws:states:ap-southeast-1:101010101010:stateMachine:ExampleStateMachine2","creationDate":1635171790840}
This error does not present itself when manually creating the state machines sequentially via AWS CLI using the exact inputs as shown in the logs.
Approach
I suspect there is some race condition in AWS Step Functions Local when multiple create requests are done concurrently. This PR simply makes the requests synchronous instead of using Promise.all and it seems to fix the issue.
Purpose
There is a strange
DUPLICATE_STATE_NAME
error when registering multiple state machines with similarly named steps, even though the state machines are named differently and should be completely independent.Serverless config:
Error:
This error does not present itself when manually creating the state machines sequentially via AWS CLI using the exact inputs as shown in the logs.
Approach
I suspect there is some race condition in AWS Step Functions Local when multiple create requests are done concurrently. This PR simply makes the requests synchronous instead of using
Promise.all
and it seems to fix the issue.