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

NotFound handler does not run internal handlers #708

Closed
DonutEspresso opened this issue Nov 17, 2014 · 0 comments
Closed

NotFound handler does not run internal handlers #708

DonutEspresso opened this issue Nov 17, 2014 · 0 comments

Comments

@DonutEspresso
Copy link
Member

I had a use case where I was trying to render a 404 page directly in the NotFound event handler, which was causing some issues. There appears to be some internal handlers that set up some initial state, and the NotFound event was not running through those internal handlers.

In my specific case, req.params was not being given an initial value, so attempting to manually invoke common handler from within the NotFound handler was causing all sorts of issues. For example, restify.queryParser and restify.bodyParser expect req.params to be initialized, so manually invoking them caused Restify to blow up.

I eventually resolved the issue by redirecting the request to a known 404 handler, which would then invoke the internal and common handler stack as expected. I suspect this was a design decision, to have the NotFound handler skip any internal handlers. This makes a lot of sense for lean REST API services, but for a more complex web app may cause some behaviors that are not immediately obvious.

retrohacker pushed a commit that referenced this issue Apr 29, 2017
Closes:

#289
#381
#474
#575
#790
#633
#717
#576
#576
#909
#875
#860
#853
#850
#829
#813
#801
#921
#1101
#1019
#989
#632
#708
#737
#859
#1326
#1327
#927
#1099
#1068
#1040
#1035
#957
#948
#1134
#1136
#1183
#1206
#1286
#1323

> Note: this issue closes _but does not resolve_ the issues listed, we are just tracking them in another medium
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants