Answer the question
In order to leave comments, you need to log in
Why can a Node.js server crash?
I am using ExpressJS. I launch the HTTP server through the http module, I launch the HTTPS server through the spdy module, so that HTTP2, the application itself is based on Next.js, I use the Routes API, I launch it according to the "Custom Server" scheme, there is a request handler for dynamic images in the server.js file:
const dynamicFileHandler = async (req, res, next) => {
try {
const filePath = path.join(process.cwd() + decodeURIComponent(req.baseUrl));
await fs.promises.access(filePath);
res.sendFile(filePath);
} catch(e) { next(); }
}
express.use("/images/*", dynamicFileHandler);
express.all("/api/*", nextHandler);
express.get("*", nextHandler);
net.js:817
bytes += el.chunk instanceof Buffer ?
^
TypeError: Cannot read property 'chunk' of null
at Socket.bytesWritten (net.js:817:17)
at Socket.socketOnError (_http_server.js:637:31)
at Socket.emit (events.js:327:22)
at Stream.onStreamError (/root/app/node_modules/spdy/lib/spdy/handle.js:110:18)
at Stream.emit (events.js:315:20)
at errorOrDestroy (/root/app/node_modules/spdy-transport/node_modules/readable-stream/lib/internal/streams/destroy.js:98:101)
at onwriteError (/root/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_writable.js:424:5)
at onwrite (/root/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_writable.js:450:11)
at WritableState.onwrite (/root/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_writable.js:160:5)
at doWrite (/root/app/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_writable.js:409:30)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question