I have the following code which makes a call to a remote service and then sends the response to the client. This app is running on a docker container on OpenShift platform.
const url = XXX, jwt = YYY;
app.get('/ccfile', (req, res)=>{
console.log(`calling backend service ...`);
try {
axios.get(url, {
headers: {
'Authorization': jwt
}
})
.then((response) => {
try {
console.log(`response.data.message: ${response.data.message}`);
console.log(`response.data.content length: ${response.data.content.length}`);
const buff = Buffer.from(response.data.measureData, "base64");
const resp = {};
resp.content = response.data.content;
resp.measureData = buff.toString("ascii");
res.on('end', () => {
console.log(`on end Response headers: ${res.headers}`);
console.log('on end res.finished: ', res.finished)
});
res.on('close', () => {
console.log(`on close Response headers: ${res.headers}`);
});
res.on('finish', () => {
console.log(`on finish Response headers: ${res.headers}`);
});
res.status(200).send(resp);
}
} catch (err) {
console.log("!!!!!!internal try catch block", err)
res.status(500).send(null);
}
})
.catch((e) => {
console.log(`capture files error [${e}]`);
res.status(500).send(null);
});
} catch (err) {
console.log("!!!!!!outer try catch error triggered", err)
res.status(500).send(null);
}
});
When the response received from the backend service is huge (>100MB), the NodeJS process is terminating connection with the client, resulting in Connection Reset error on the client side. I noticed that whenever this issue happens, the NodeJS process is getting restarted and I could see some log messages that have the word SIGKILL. I am assuming this means either the OS or something else is trying to kill the nodejs process due to some constraints.
> [email protected] start
> node index.js
[2025-02-04T21:32:29.699Z] Listening at http://localhost:8080
[2025-02-04T21:33:27.148Z] calling backend service .....
[2025-02-04T21:34:12.334Z] response.data.message: Content retrieved successfully
[2025-02-04T21:34:12.334Z] response.data.content length: 444103712
[2025-02-04T21:34:12.334Z] response headers before send Object [AxiosHeaders] {
'x-backside-transport': 'OK OK',
connection: 'Keep-Alive',
'transfer-encoding': 'chunked',
'content-type': 'application/json',
server: 'Microsoft-IIS/10.0',
'x-powered-by': 'ASP.NET',
date: 'Tue, 04 Feb 2025 21:33:44 GMT',
'x-global-transaction-id': 'be53b51667a287a73d3b797f'
}
npm http fetch GET 200 475ms
npm notice
npm notice New major version of npm available! 10.7.0 -> 11.1.0
npm notice Changelog: .1.0
npm notice To update run: npm install -g [email protected]
npm notice
npm error path /opt/app-root/src
npm error command failed
npm error signal SIGKILL
npm error command sh -c node index.js
Does anyone have an idea what is causing the SIGKILL command sent to be sent to the process and what can be done to resolve this issue? Unfortunately, streaming the response as is to the client is not an option as I have to modify the response before sending it to the client.