---
title: "Comment by Jason Jiang on \"A guide to reading and writing Node.js streams\" | Hashnode"
description: "Thanks for the great guide, and I was confused with the Writeable demo: Why the \"wait drain\" was logged after only one HELLO is logged to stdout, I assume the b"
url: "https://hashnode.com/posts/a-guide-to-reading-and-writing-nodejs-streams/668fd751e5d695eed5680b4d/comment/6698f792d8d1c8446fa805d5"
---

[Discussion](https://hashnode.com/posts/a-guide-to-reading-and-writing-nodejs-streams/668fd751e5d695eed5680b4d)

Comment [A guide to reading and writing Node.js streams](https://hashnode.com/posts/a-guide-to-reading-and-writing-nodejs-streams/668fd751e5d695eed5680b4d)

[Jul 18, 2024](https://hashnode.com/posts/a-guide-to-reading-and-writing-nodejs-streams/668fd751e5d695eed5680b4d/comment/6698f792d8d1c8446fa805d5)

Thanks for the great guide, and I was confused with the Writeable demo: Why the "wait drain" was logged after only one HELLO is logged to stdout, I assume the buffer was empty after the first HELLO logged, the 2nd HELLO should also be logged before the first "wait drain", not sure where did i misunderstood, is this because the stdout.write is async, after calling the "cb", the "hello" in the buffer will be removed?

[Matteo Collina](https://hashnode.com/@matteocollina)

Open Sourcerer, Node.js TSC member, Fastify Lead Maintainer

[Jul 25, 2024](https://hashnode.com/posts/a-guide-to-reading-and-writing-nodejs-streams/668fd751e5d695eed5680b4d/comment/6698f792d8d1c8446fa805d5#reply-66a2236196271f659e5801b5)

Good spot! The buffer is flushed on first write. Because the `cb` will be called after an event loop turn (it's async!), we need to wait for `drain`. To counteract this effect there are cork() and uncork(). They are used to send out the http headers for example.
