Unverified Commit 19b44854 authored by Anna Henningsen's avatar Anna Henningsen Committed by Ruben Bridgewater
Browse files

stream: remove `undefined` check

`validChunk` allowed `undefined` as a chunk in object mode; however,
this was redundant, since:

- `validChunk()` is only used by `.write()`
- If the `validChunk()` check passes for `undefined`, `.write()`
  calls `writeOrBuffer()`
- If `writeOrBuffer()` does not receive a Buffer, it calls
  `decodeChunk()`
  - `decodeChunk()` ignores `undefined` because it checks
    `typeof chunk === 'string'`
  - After that call, `chunk.length` is accessed, which throws an
    error if `chunk` is undefined`.

This “fixes” a bug in the sense that `state.pendingcb` is no longer
incremented for write attempts that fail like this.

PR-URL: https://github.com/nodejs/node/pull/17644


Reviewed-By: default avatarRuben Bridgewater <ruben@bridgewater.de>
Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarLuigi Pinca <luigipinca@gmail.com>
Reviewed-By: default avatarAnatoli Papirovski <apapirovski@mac.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
Reviewed-By: default avatarJon Moss <me@jonathanmoss.me>
parent c8ac188e
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment