[useResponseCache] Promise rejections from cache impl are not handled #2240
Labels
kind/bug
Something isn't working
stage/4-pull-request
A pull request has been opened that aims to solve the issue
Issue workflow progress
Progress of the issue based on the
Contributor Workflow
minimal reproduction available on
Stackblitz.
@envelop/*
packages that you are using.Describe the bug
The cache implementation can be sync or async - each of the methods can return a Promise. However, these promises are not awaited or handled so they end up as "floating promises". When one of these rejects, Node treats it as an unhandled promise rejection and, under default behaviour
To Reproduce Steps to reproduce the behavior:
set
which returns a rejected promise.cache.set
isn't awaited, but in the background the Node processes crashes.We noticed this whilst using
@envelop/response-cache-redis
with a Redis setup that wasn't configured correctly, however, the incorrect error handling can be reproduced with anything that returns a rejected promise.Expected behavior
The rejected promise should be returned through
onExecuteDone
so it can be handled by the server and result in a failed request. The process should not get terminated.Environment:
@envelop/*
versions:@envelop/response-cache
:6.1.2
The text was updated successfully, but these errors were encountered: