Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:455:11)
at ServerResponse.header (C:\Users\raul.aguila\Documents\api\payfast\node_modules\express\lib\response.js:771:10)
at ServerResponse.send (C:\Users\raul.aguila\Documents\api\payfast\node_modules\express\lib\response.js:170:12)
at ServerResponse.json (C:\Users\raul.aguila\Documents\api\payfast\node_modules\express\lib\response.js:267:15)
at Query.<anonymous> (C:\Users\raul.aguila\Documents\api\payfast\controllers\pagamentos.js:22:18)
at Query.<anonymous> (C:\Users\raul.aguila\Documents\api\payfast\node_modules\mysql\lib\Connection.js:525:10)
at Query._callback (C:\Users\raul.aguila\Documents\api\payfast\node_modules\mysql\lib\Connection.js:491:16)
at Query.Sequence.end (C:\Users\raul.aguila\Documents\api\payfast\node_modules\mysql\lib\protocol\sequences\Sequence.js:83:24)
at C:\Users\raul.aguila\Documents\api\payfast\node_modules\mysql\lib\protocol\Protocol.js:404:18
at Array.forEach (<anonymous>)
[nodemon] app crashed - waiting for file changes before starting...
A aplicação está persistindo normalmente os pagamentos e também retornando o pagamentos em json como respostas, mas dá esse erro no final. Alguém teve o mesmo erro e conseguiu resolver?
Obrigado.