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

404 gives error #16

Closed
Torsph opened this issue Nov 13, 2014 · 4 comments · Fixed by #17
Closed

404 gives error #16

Torsph opened this issue Nov 13, 2014 · 4 comments · Fixed by #17
Assignees
Labels
bug
Milestone

Comments

@Torsph
Copy link
Contributor

@Torsph Torsph commented Nov 13, 2014

Hi!

It looks like vision gives a error on 404 pages and just hangs the server. I will look into it later, but for now I just thought you should know. Maybe it is some easy error? Or is it related to the updates you are making on the hapi 8.0 release?

Debug: hapi, internal, implementation, error
    TypeError: Cannot read property 'hasOwnProperty' of undefined
    at /Users/Torsph/Development/node/aam/node_modules/hapi/node_modules/vision/lib/index.js:329:20
    at /Users/Torsph/Development/node/aam/node_modules/hapi/node_modules/vision/lib/index.js:432:20
    at Object.engine.compileFunc (/Users/Torsph/Development/node/aam/node_modules/hapi/node_modules/vision/lib/index.js:162:24)
    at /Users/Torsph/Development/node/aam/node_modules/hapi/node_modules/vision/lib/index.js:422:16
    at fs.js:291:14
    at Object.oncomplete (fs.js:97:15)
@Torsph

This comment has been minimized.

Copy link
Contributor Author

@Torsph Torsph commented Nov 13, 2014

So it looks like the context is the problem.

reply.view('some_template'); //Don't work
reply.view('some_template', {}); //Works

In vision/index.js the context is default set to null it will fail on different methods like context.hasOwnProperty. Should it maybe be set to a default empty object? However, will a empty object make the coverage go down because of the code on line 272 in index.js.

@jagoda

This comment has been minimized.

Copy link
Contributor

@jagoda jagoda commented Nov 13, 2014

@Torsph It looks to me like this issue only occurs when no global context is supplied, no handler context is supplied, and a layout template is being used. Does that sound consistent with your experience?

Making the default global context an empty object will cause handler supplied context objects to be copied unnecessarily. Instead, what do you think about doing something like context = context || {} after the global context is processed (line 285)?

@Torsph

This comment has been minimized.

Copy link
Contributor Author

@Torsph Torsph commented Nov 13, 2014

@jagoda Thats correct. It is consistent with my experience. Totally agree with you about the unnecessarily copy of the context.

context = context || {} sounds like a good option. I can make the pull request, if you don't want to :)

@jagoda

This comment has been minimized.

Copy link
Contributor

@jagoda jagoda commented Nov 13, 2014

Go for it! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.