Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Build a Simple Dynamic Site with Node.js Handling Routes in Node.js Populating User Information

Justin Coen
seal-mask
.a{fill-rule:evenodd;}techdegree
Justin Coen
Full Stack JavaScript Techdegree Student 12,829 Points

Error in Andrew's profile.js code - FIXED: Concurrent Requests Recive Mixed Responses

This isn't a question but rather a solution to a problem I found when 2 or more requests are made simultaneously.

If 2+ requests are made the response is likely to respond with the data from another request, or error out. This was very odd, seeing as how nodeJS handles responses based on the specific request which was received.

The problem came to be that, in profile.js, the variable

profileEmitter = this;

was not declared with var.

When this happens the variable is set to the Global Scope, thus creating errors when multiple requests are made. Simply setting

var profileEmitter = this;

fixed this issue.

http://stackoverflow.com/questions/10509187/2-concurrent-requests-getting-mixed-up-in-node-js-app

jsdevtom
jsdevtom
16,963 Points

Thanks :-) It's awesome when people share the solution instead of keeping the knowledge to themselves!