node-ts / bus

A typescript based enterprise service bus framework based on enterprise integration patterns
https://bus.node-ts.com/
MIT License
270 stars 26 forks source link

Replace async_hooks with cls-hooked #219

Closed adenhertog closed 7 months ago

adenhertog commented 7 months ago

Replaces the 'async_hooks' implementation of 'message-handling-context' with 'cls-hooked'.

There's a suspicion that the message-handling-context is leaking message contexts when used in highly parallel services. This can cause issued with handlers that depend on message attributes, particularly workflows that are mapped using correlationIds, to become out of sync.

'cls-hooked' has been integrated, which under the hood still uses the native node 'async_hooks', however does it in a much better tested and solid way.

Tests have been introduced to illustrate that no context has been leaked when running multiple instances of a workflow in parallel.