Skip to content

Commit

Permalink
docs: fix streams example for write() after end()
Browse files Browse the repository at this point in the history
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 nodejs#8814

Signed-off-by: Julien Gilli <julien.gilli@joyent.com>
  • Loading branch information
a0viedo authored and Julien Gilli committed Dec 7, 2014
1 parent 5e503f4 commit f5cb330
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doc/api/stream.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit f5cb330

Please sign in to comment.