Skip to content
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

[Restify 7] Fix uncaught exceptions triggering route lookups #1717

Merged
merged 3 commits into from Nov 16, 2018

Conversation

mridgway
Copy link
Contributor

Pre-Submission Checklist

  • Opened an issue discussing these changes before opening the PR
  • Ran the linter and tests via make prepush
  • Included comprehensive and convincing tests for changes

Issues

The current uncaughtException handler attempts to do route lookup if a string is thrown. This behavior is undesirable because it prevents the application from handling the exceptions itself (it never makes it to the user's uncaughtException handler.

Changes

This PR adds a check to the route lookup logic which is typically used when calling next('myString'). It bypasses this code if it handling an uncaught exception.

The test demonstrates how this could be triggered before these code changes: throw 'bar'. I also had to add a check for err.name since that would throw another error in the case of a string being passed to the errEvtNameFromError function. I made the default an empty string, but could use some feedback on whether that makes sense or not.

test/server.test.js Show resolved Hide resolved
lib/server.js Show resolved Hide resolved
Copy link
Member

@hekike hekike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment, thanks for the PR and covering the edge cases!

lib/server.js Outdated Show resolved Hide resolved
@hekike hekike merged commit e49cb3b into restify:master Nov 16, 2018
@mridgway mridgway deleted the fixUncaughtRouteLookup branch November 26, 2018 23:12
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.

None yet

2 participants