sam-goodwin / eventual

Build scalable and durable micro-services with APIs, Messaging and Workflows
https://docs.eventual.ai
MIT License
174 stars 4 forks source link

fix: service without open search throws errors #432

Closed thantos closed 1 year ago

thantos commented 1 year ago

Found by @mattduran420

When a service did not have an open search index, commands, workflows and more would fail. Use the service spec to determine if the client needs to be created or now (presence of an index) which matches the logic to create the infra in CDK.

Ran the runtime tests without open search and proved that all workflows and commands did stop working.

After this change, tests pass without and without open search.

{
    "errorType": "Error",
    "errorMessage": "Expected env variable EVENTUAL_OPENSEARCH_ENDPOINT to be present.",
    "stack": [
        "Error: Expected env variable EVENTUAL_OPENSEARCH_ENDPOINT to be present.",
        "    at assertNonNull (/packages/@eventual/core/src/internal/util.ts:9:11)",
        "    at tryGetEnv (/packages/@eventual/aws-runtime/src/env.ts:32:10)",
        "    at openSearchEndpoint (/packages/@eventual/aws-runtime/src/env.ts:41:3)",
        "    at <anonymous> (/packages/@eventual/aws-runtime/src/create.ts:295:15)",
        "    at <anonymous> (/packages/@eventual/aws-runtime/src/handlers/orchestrator.ts:45:23)"
    ]
}

Note: Ideally we'd also be able to remove the OpenSearch deps from the tree, but this is a good start.