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

Unable to provide views override in onPreResponse #1924

Closed
mshick opened this issue Sep 10, 2014 · 4 comments
Closed

Unable to provide views override in onPreResponse #1924

mshick opened this issue Sep 10, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@mshick
Copy link

@mshick mshick commented Sep 10, 2014

I receive the following error:

TypeError: Uncaught error: Converting circular structure to JSON
    at Object.stringify (native)
    at Error.internals.annotate (.../node_modules/joi/lib/errors.js:120:26)
    at Object.exports.assert (.../node_modules/hapi/lib/schema.js:15:104)
    at new exports.Response.internals.Response (.../node_modules/hapi/lib/views.js:390:12)

Background on this -- I have an onPreResponse handler set up to print an error page view. I've generally assumed it would use the server's default view settings. In this case, however, I installed Lout and put auth on the /docs url. Whenever the unauthorized error is triggered, it hits my pre-response handler, and the reply.view() call is resolved in Lout's templates, not my server's. (That in itself might be a bug).

Then, in my attempts to fix this I tried a view override for the reply.view('error') call I'm making. Unfortunately, specifying the engine hbs: require(handlebars) gives me that circular structure error...

@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Sep 10, 2014

First, you can't specify an engine in a reply.view() call. What version are you on? I thought I fixed that assertion check.

Second, lout's engine should not leak into your app. That sounds like a bug.

@hueniverse
Copy link
Contributor

@hueniverse hueniverse commented Sep 10, 2014

Can you reproduce the lout issue with an example you can share?

@mshick
Copy link
Author

@mshick mshick commented Sep 10, 2014

Was on 6.7, just upped to 6.8 with same results.

If the leaking engine is the issue I’ll try to set up an isolated test and respond if I get the same results.

Good to know about the engine, makes sense.

On Sep 9, 2014, at 11:03 PM, Eran Hammer notifications@github.com wrote:

First, you can't specify an engine in a reply.view() call. What version are you on? I thought I fixed that assertion check.

Second, lout's engine should not leak into your app. That sounds like a bug.


Reply to this email directly or view it on GitHub #1924 (comment).

@mshick
Copy link
Author

@mshick mshick commented Sep 18, 2014

Apologies for how long it took me to respond.

I set up the following test to confirm that the preResponse handler does seem to inherit the view engine of the response handler itself.

Here's a Gist -- using latest Hapi, Handlebars and Lout: https://gist.github.com/mshick/6a201cff67d1580d037e

You'll see it's looking for an html template (which Lout set up) in the lout/templates directory.

It's worth mentioning, I can change the template path via the override, but since the engine is fixed per your earlier point, I can't really get around this.

@hueniverse hueniverse added the bug label Sep 19, 2014
@hueniverse hueniverse self-assigned this Sep 19, 2014
@hueniverse hueniverse added this to the 6.9.0 milestone Sep 19, 2014
@geek geek closed this in #1959 Sep 22, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants