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 trialaditigreen
6,730 PointsI am getting an unhandled error event after viewing the webpage
After I run the app.js file, I view the webpage. I come back and in the console, I get this error message:
Server running at port: 3000
events.js:160
throw er; // Unhandled 'error' event
^
Error: write after end
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:426:15)
at /home/treehouse/workspace/renderer.js:8:11
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)
treehouse:~/workspace$ node app.js
Server running at port: 3000
events.js:160
throw er; // Unhandled 'error' event
^
Error: write after end
at ServerResponse.OutgoingMessage.write (_http_outgoing.js:426:15)
at /home/treehouse/workspace/renderer.js:6:11
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:439:3)
1 Answer
Seth Kroger
56,413 PointsFor an error message this one is fairly straight-forward, "Error: write after end". Once you call response.end() you can write to it anymore because the response is supposed to be closed out after that. Calling response.write() after that causes the error.
You can post your code if you still need help finding the problem.
Caroline olijve
Courses Plus Student 14,499 PointsCaroline olijve
Courses Plus Student 14,499 PointsTo spare some people with a similar problem some time of frustration: One possibility , apart from the obvious
.end
in the wrong place, is that you set theif(username.length > 0)
-statement of the user-function in the router.js file toif(username.length >= 0)