Skip to content

Avoid installing a global uncaughtException handler on import - #112

Open
PNHD wants to merge 2 commits into
daquinoaldo:masterfrom
PNHD:fix/import-uncaught-exception-handler
Open

Avoid installing a global uncaughtException handler on import#112
PNHD wants to merge 2 commits into
daquinoaldo:masterfrom
PNHD:fix/import-uncaught-exception-handler

Conversation

@PNHD

@PNHD PNHD commented Aug 14, 2026

Copy link
Copy Markdown

Pull Request Details

Related Issue

Addresses #77.

Importing https-localhost currently installs a process-wide uncaughtException handler even when the package is only used as a module. That changes application-level error handling and can hide the original stack-trace behavior.

This change scopes the existing handler to the CLI path (require.main === module) so the CLI keeps its friendly EACCES / EADDRINUSE messages while library consumers no longer get a global process listener as a side effect of require("https-localhost").

A regression test re-imports the module after clearing the require cache and verifies that the uncaughtException listener count does not change.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have updated the documentation or my changes dont require it.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

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