[whatwg/streams] Why does call to pipeThrough throw Uncaught TypeError: Cannot convert undefined or null to object? (#754)

According to [Chrome Platform Status Streams API: piping Network / Connectivity](https://www.chromestatus.com/feature/6067348976959488) `.pipeTo()` is defined at Chrome 59.

The specification describes the pattern as 

> [3.2.4.4. `pipeThrough({ writable, readable }, options)`](https://streams.spec.whatwg.org/#rs-pipe-through)

At an [example](https://github.com/whatwg/streams/blob/a78e1ae670c68d4d80b2ffa10c85c25eaa82bf37/demos/streaming-element-backpressure.html) within the repository the code used is 

```
  await response.body
      .pipeThrough(new TextDecoder())
```

Tried code below at `console` at Chromium 59 while attempting to gather the concept and appropriate pattern and expected parameters for `.pipeThrough()`

```
let n = 0;
let text = "a";

let readableStream = new ReadableStream({
  pull(c) {
    if (++n < 10) c.enqueue(text)
    else c.close();
  }
});

readableStream
.pipeThrough(new TextEncoder())
.pipeTo(new WritableStream({
  write(chunk) {
    console.log("Chunk received", chunk);
  },
  close() {
    console.log("All data successfully read!");
  },
  abort(e) {
    console.error("Something went wrong!", e);
  }
}))
```
which logged 

```
Uncaught TypeError: Cannot convert undefined or null to object
    at hasOwnProperty (<anonymous>)
```

Downloaded repository and tried the same code at `console` at above linked example `document`, which logged expected result.

Questions:

1) Why does Chromium 59 throw a `TypeError` though `.pipeThrough()` is defined at `ReadableStream` object?

2) What is the proper parameter pattern expected by `.pipeThrough()`? For example, does `ReadableStream().pipeThrough(new WritableStream(), new ReadableStream())` reflect the expected parameters passed to the function?

3) Is `/streams-master/demos/transforms/transform-stream-polyfill.js` which is loaded at the example currently necessary to use `.pipeThrough()` at Chromium browser?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/754

Received on Saturday, 22 July 2017 04:02:54 UTC