moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 119 forks source link

fix: #298: register on close and error event on response #299

Closed giovanni-bertoncelli closed 2 years ago

giovanni-bertoncelli commented 2 years ago

Resolves #298. Added handlers to handle error and close events on response and resolve/reject respectively the context caller.

icebob commented 2 years ago

Great, thanks!

giovanni-bertoncelli commented 2 years ago

@icebob maybe the call should be always resolved instead of rejected since if rejected moleculer tries to write the headers, but since the response stream has already started the headers are surely already been written. Which approach do you prefer?

icebob commented 2 years ago

Can we check that the response stream is started? And in this case, we block the header sending.

giovanni-bertoncelli commented 2 years ago

@icebob how can we do that? By resolving if headersSent is true? And rejecting otherwise?

(BTW @michelevincenzi is my colleague, we're working together on this)

icebob commented 2 years ago

we can reject, but check the headersSent value in sendError.