-
-
Notifications
You must be signed in to change notification settings - Fork 307
Suppress error events. #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Fixes: node:events:353 throw er; // Unhandled 'error' event ^ Error: read ECONNRESET at TCP.onStreamRead (node:internal/stream_base_commons:213:20) Emitted 'error' event on Socket instance at: at emitErrorNT (node:internal/streams/destroy:188:8) at emitErrorCloseNT (node:internal/streams/destroy:153:3) at processTicksAndRejections (node:internal/process/task_queues:80:21) { errno: -54, code: 'ECONNRESET', syscall: 'read' } npm ERR! code 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses unhandled error events that were causing the application to crash with ECONNRESET errors by adding an empty error handler to the response object.
- Adds an error event listener to suppress connection reset errors
- Prevents application crashes from unhandled socket errors
@@ -16,6 +16,7 @@ module.exports.fake_response = function fake_response(req, res) { | |||
} | |||
r.push(''); | |||
r.push(''); | |||
res.on('error', () => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silently suppressing all errors with an empty handler is risky and makes debugging difficult. Consider logging the error or handling specific error types appropriately.
res.on('error', () => {}); | |
res.on('error', (err) => { | |
console.error('Error in fake_response res:', err); | |
}); |
Copilot uses AI. Check for mistakes.
@@ -16,6 +16,7 @@ module.exports.fake_response = function fake_response(req, res) { | |||
} | |||
r.push(''); | |||
r.push(''); | |||
res.on('error', () => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty error handler provides no context about what errors are being suppressed. At minimum, consider adding a comment explaining why errors are being ignored or log them for debugging purposes.
res.on('error', () => {}); | |
res.on('error', (err) => { | |
// Log the error for debugging purposes | |
console.error('Error in fake_response:', err); | |
}); |
Copilot uses AI. Check for mistakes.
Fixes: