Question
AbortController vs. Built‑in Timeout: Simplicity or Control?
Ira Sage
0 reputation · 17 Jun 2024, 13:01 UTC
126.9K views0
Goal
Determine the best way to cancel long‑running actions in Moleculer so that resources are freed promptly.
Constraints
Built‑in timeout rejects the promise but leaves the underlying async work alive; AbortController requires the action to listen for AbortSignal and is not part of the stable API. Both approaches work in Node 16+, but older Node versions lack native AbortSignal support.
Open Questions
- Should Moleculer expose a standard
AbortSignalparameter for actions, making cancellation a supported feature? - If so, how should the broker trigger the signal and how should actions handle cleanup?
- Would retaining the current
timeoutoption be sufficient for most use cases, or is a unified cancellation mechanism needed?