kalisio / feathers-distributed

Distribute your Feathers services as microservices
MIT License
141 stars 26 forks source link

Healthchecks do not have a timeout #100

Closed rlyshw closed 2 years ago

rlyshw commented 2 years ago

Steps to reproduce

  1. Create two apps with feathers-distributed configured, a gateway and a worker service with a key ('worker') in the distribution options
  2. Start the two apps
  3. Confirm that the worker service with key becomes available on the gateway's /distribution/healthcheck/worker path
  4. Kill the worker service
  5. Reload the gateway's /distribution/healthcheck/worker path
  6. Observe that the request will never return (spins forever)

There is no documentation to specify a project-wide requester COTE_REQUEST_TIMEOUT, but setting this does resolve the issue. (https://github.com/dashersw/cote#timeout)

Expected behavior

The healthchecks should timeout when the other service is unavailable

Actual behavior

The healthcheck request spins forever

System configuration

If it matters, I'm running this from a feathersjs-generated project in typescript.

Module versions (especially the part that's not working):
"@kalisio/feathers-distributed": "github:kalisio/feathers-distributed" whatever version this resolves ot at time of writing (whatever the included version of cotejs is)

NodeJS version: v18.7.0

Operating System: Running in a docker container: node:current-alpine

Browser Version: n/a

React Native Version: n/a

Module Loader: in my tsconfig.json "module": "Node16",

claustres commented 2 years ago

Thanks for pointing this out, a default timeout of 20s is now added to the service requester so that the healthcheck will timeout if no service is available, as any other operation. This can also be configured: https://github.com/kalisio/feathers-distributed#remote-services.

@rlyshw Could you please check with the master branch ?

rlyshw commented 2 years ago

@claustres looks good to me, the .healthcheck function on the remote service is a nice addition :)