Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jameshilliard
Copy link
Contributor

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

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
Copy link

@Copilot Copilot AI left a 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', () => {});
Copy link
Preview

Copilot AI Aug 7, 2025

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.

Suggested change
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', () => {});
Copy link
Preview

Copilot AI Aug 7, 2025

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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant