Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/jss.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ program
process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);

// Gracefully handle ECONNRESET — normal network noise from clients
// closing connections early (browser navigation, health checks, etc.)
process.on('uncaughtException', (err) => {
if (err.code === 'ECONNRESET' || err.code === 'EPIPE' || err.code === 'ECONNABORTED') {
return;
}
console.error('Uncaught exception:', err);
process.exit(1);
});

} catch (err) {
console.error(`Error: ${err.message}`);
process.exit(1);
Expand Down
11 changes: 10 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ export function createServer(options = {}) {
disableRequestLogging: true,
trustProxy: true,
// Handle raw body for non-JSON content
bodyLimit: 10 * 1024 * 1024 // 10MB
bodyLimit: 10 * 1024 * 1024, // 10MB
// Gracefully handle client TCP errors (ECONNRESET, EPIPE, etc.)
clientErrorHandler: (err, socket) => {
if (err.code === 'ECONNRESET' || err.code === 'EPIPE' || err.code === 'ECONNABORTED') {
socket.destroy();
return;
}
// Default Fastify behavior for other client errors
socket.destroy(err);
}
};

// Add HTTPS support if SSL config provided
Expand Down