camunda / camunda-8-js-sdk

The Camunda 8 JavaScript SDK for Node.js
https://camunda.github.io/camunda-8-js-sdk/
Apache License 2.0
19 stars 6 forks source link

docs: ZEEBE_ADDRESS defaults to `localhost` and used when ZEEBE_GRPC_ADDRESS is set #245

Closed pafmaf closed 1 month ago

pafmaf commented 2 months ago

Hi! This is something that was not obvious to us during setup / configuration. Should be a simple fix if you know how it is supposed to work. Please clarify :)

SDK Component

Docs

Expected Behavior

README explains when and how to set ZEEBE_ADDRESS when ZEEBE_GRPC_ADDRESS was already set.

Current Behavior

ZEEBE_ADDRESS is not mentioned in the README. It is documented somewhere else, as "Zeebe Gateway Address". It's still used and we, for example, need to set it like ZEEBE_ADDRESS = ZEEBE_GRPC_ADDRESS. The given examples did not work, since it defaults to localhost....

export ZEEBE_GRPC_ADDRESS='5c34c0a7-7f29-4424-8414-125615f7a9b9.syd-1.zeebe.camunda.io:443'
export ZEEBE_REST_ADDRESS='https://syd-1.zeebe.camunda.io/5c34c0a7-7f29-4424-8414-125615f7a9b9'
export ZEEBE_CLIENT_ID='yvvURO9TmBnP3zx4Xd8Ho6apgeiZTjn6'
export ZEEBE_CLIENT_SECRET='iJJu-SHgUtuJTTAMnMLdcb8WGF8s2mHfXhXutEwe8eSbLXn98vUpoxtuLk5uG0en'

Possible Solution

Explain when ZEEBE_ADDRESS is required to be set / when it is used / how the setup is intended to work with multiple config values: ZEEBE_ADDRESS + ZEEBE_GRPC_ADDRESS (or ZEEBE_REST_ADDRESS).

jwulf commented 2 months ago

Sorry that this isn't working as expected, and THANKS for finding and reporting this.

I'll take a look at it tomorrow and push a fix in the next day or two.

jwulf commented 2 months ago

This is where it happens: line 138 in src/zeebe/zb/ZeebeGrpcClient.ts:

this.gatewayAddress = RequireConfiguration(
    config.ZEEBE_ADDRESS || config.ZEEBE_GRPC_ADDRESS,
    'ZEEBE_GRPC_ADDRESS'
)

The Configuration hydration defaults ZEEBE_ADDRESS to localhost:26500.

If we change this to have no default, and instead default ZEEBE_GRPC_ADDRESS to localhost:26500 we will preserve the existing behaviour: no explicit configuration defaults to localhost:26500. And an explicit ZEEBE_GRPC_ADDRESS will not be overridden by a default.