-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
I am trying to send buffer data as response but the server is crashing when I do that. Below is the code to reproduce the issue.
app.get("/test", async(req, res) => {
res.header("Content-Type", "application/octet-stream");
console.log("test")
const binaryData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
const buffer = Buffer.from(binaryData);
res.send(buffer);
})
Even using below code doesn't catch the error.
process
.on('unhandledRejection', (reason, p) => {
console.error(reason, 'Unhandled Rejection at Promise', p);
})
.on('uncaughtException', err => {
console.error(err, 'Uncaught Exception thrown');
process.exit(1);
});
I noticed that the crash only happens when I run in docker container. It doesn't crash when running locally using ts-node src/index.ts
. Below is my Dockerfile.
FROM node:22-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 3000
ENV NODE_OPTIONS="--enable-source-maps"
CMD ["node", "dist/index.js"]
There are no error messages or stack traces printed. Container just stops. As a workaround I'm converting it to base64 and sending json response.
Metadata
Metadata
Assignees
Labels
No labels