Avoid trying to send a response to API calls after we've already sent an error

In some cases we were using early `return res.status(...).send(...)` to send 400 errors
but this happened inside a promise chain that later sent another status and response.

We fix this with the correct indentation of the success response so that an early return doesn't fall there.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2018-03-09 14:48:34 -08:00
parent 79b4d39acd
commit f76aacc7fb

View File

@ -136,7 +136,7 @@ createApplicationManagerRouter = (applications) ->
.then (app) ->
service = app?.services?[0]
if !service?
return res.status(400).send('App not found after running action')
throw new Error('App not found after running action')
return service
.then (service) ->
res.status(200).json({ containerId: service.containerId })