Skip to content

Commit 524882f

Browse files
a0viedobnoordhuis
authored andcommitted
doc: change write() after end() streams example
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. Fixes nodejs/node-v0.x-archive#8814. PR-URL: #155 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Brendan Ashworth <[email protected]>
1 parent db595b2 commit 524882f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

doc/api/stream.markdown

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,10 @@ Calling [`write()`][] after calling [`end()`][] will raise an error.
585585

586586
```javascript
587587
// write 'hello, ' and then end with 'world!'
588-
http.createServer(function (req, res) {
589-
res.write('hello, ');
590-
res.end('world!');
591-
// writing more now is not allowed!
592-
});
588+
var file = fs.createWriteStream('example.txt');
589+
file.write('hello, ');
590+
file.end('world!');
591+
// writing more now is not allowed!
593592
```
594593

595594
#### Event: 'finish'

0 commit comments

Comments
 (0)