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 Creating a Basic Template Engine in Node.js Reading from Files

Ernest Son
Ernest Son
13,532 Points

unhandled 'error' event

everything works, except when i try "../chalkers123" the server kicks out, saying..

events.js:85
throw er; // Unhandled 'error' event
^
Error: write after end
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:413:15)
at Object.view (/home/treehouse/workspace/renderer.js:9:14)
at Profile.<anonymous> (/home/treehouse/workspace/router.js:41:16)
at Profile.emit (events.js:107:17)
at IncomingMessage.<anonymous> (/home/treehouse/workspace/profile.js:37:36) at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)

here's my current state of workspace. I combed through the files, didn't find any issues!

https://w.trhou.se/rlb3t5jirs

Ernest Son
Ernest Son
13,532 Points

funny thing, if i use another erroneous username, besides chalkers123, i get the view....sometimes

2 Answers

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Ernest,

I forked the workspace and tried accessing /chalkers123 and got the expected result. I've tried several times without an error. Due to the error message and the nature of the problem, seems like it maybe caused by connectivity issues.

I hope this helps.

Also having the same issue. Would you say, if my code is identical to @Ernest that I shouldn't worry about this?

To answer my own question: Yup! Seems like this is just a connection issue. Sometimes the error happens, sometimes it doesn't. I wouldn't worry about it.

I think I have figured out the cause of this. (not the solution). In Chrome (not tested in other browsers), if I type "chalkers" Chrome will send the GET request before I actually hit enter (if I have previously typed "chalkers", as if it is anticipating the url. (I see this because I added a massive amount of logging.) Once I hit enter, another "/chalkers" GET request is sent. So in my console logging I see two GET requests come in. The first GET request processes and sends the response and everything is displayed on the screen (which is why it always renders in the browser correctly). The second GET response sends the same data but then crashes the console app immediately after ending the response.

I can't be sure, but I only see it crash when I see Chrome sending to simultaneous GET requests.

UPDATE

In order to get Chrome to send two GET requests, you need to come from a different page, say "/", let that page load, then start added "chalkers" to the url in the address bar in Chrome, (it will send the request), and then hit Enter (then it will send the second request). Every time I do this, app.js crashes.

Ryan Boone
Ryan Boone
26,518 Points

It's throwing the same error in Safari.