From f5cb330ab13de7d80aac6891f07abcb1b73da615 Mon Sep 17 00:00:00 2001 From: Alejandro Oviedo Date: Sat, 6 Dec 2014 03:44:46 -0300 Subject: [PATCH] docs: fix streams example for write() after end() Currently there's an example using http.ServerResponse stream, which has a known bug and will not throw an error while writing after end(). Changed to a writable stream from fs which behaves as expected. fix #8814 Signed-off-by: Julien Gilli --- doc/api/stream.markdown | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown index 5a823e72385..3230a59276c 100644 --- a/doc/api/stream.markdown +++ b/doc/api/stream.markdown @@ -521,11 +521,10 @@ Calling [`write()`][] after calling [`end()`][] will raise an error. ```javascript // write 'hello, ' and then end with 'world!' -http.createServer(function (req, res) { - res.write('hello, '); - res.end('world!'); - // writing more now is not allowed! -}); +var file = fs.createWriteStream('example.txt'); +file.write('hello, '); +file.end('world!'); +// writing more now is not allowed! ``` #### Event: 'finish'