Running into unimplemented functionality

#1

I recently started working on something that tried to take better advantage of the webworker specific APIs, but I’m finding unimplemented methods here and there.

For example, the constructor for ReadableStream, when called, will throw an error saying that it’s not implemented. Additionally, chaining TransformStreams with ReadableStream.pipeThrough() will also throw a not implemented error.

Are there plans to implement these? Is there a secret list of unimplemented methods to avoid?

#2

I presume you are using the Editor, have you tried in production?
Some features are not implemented on the editor.

1 Like
#3

Sorry, I should have stated that this occurred in production.

EDIT: The exact errors that I get are.

Error: Failed to construct 'ReadableStream': the constructor is not implemented.
TypeError: Inter-TransformStream ReadableStream.pipeTo() is not implemented.

Just in case anyone else is running into the same problem in the future, I’m getting around this by using a TransformStream to create instances of ReadableStream and manually piping between them.

i.e. something like this

const ts = new TransformStream();
(async function() {
    const w = ts.writable.getWriter();
    for (const buf of buffers) {
        await w.write(buf);
    }
    w.close();
})();
return ts.readable;
#4

Hi @ssttevee,

We don’t have immediate plans to implement custom ReadableStreams, since identity TransformStreams tend to suffice for the same tasks. We do have plans to implement inter-TransformStream piping, but I’m not sure when we’ll get to it. I’m curious if you can share your use case that requires it?

We don’t have an explicit list of unimplemented functionality, since it changes rapidly. The closest thing to a list would be our documentation here: https://developers.cloudflare.com/workers/reference/#

Harris

#5

Hi @harris,

I’m using one TransformStream to encrypt data and another to calculate and append a checksum to the end of the stream. Although it isn’t exactly hard to put them together, it allows better reusability.

Additionally, I don’t think the transformer parameter in TransformStream works. I did a simple test:

function (request) {
    let n = 1;
    const ts = new TransformStream({
        start: () => { },
        transform(chunk, controller): void {
            controller.enqueue(new Uint8Array(`received chunk ${n}\n`.split('').map((c) => c.charCodeAt(0))));
        },
        flush(controller): void {
            controller.enqueue(new Uint8Array(`all chunks received\n`.split('').map((c) => c.charCodeAt(0))));
        }
    });

    return new Response(request.body.pipeThrough(ts));
}

and my curl request is just echoed the data I sent.

#6

That makes a lot of sense, thank you. I agree that this is necessary for code reusability. I’m not sure when exactly we will get to enabling inter-TransformStream piping, but it’s definitely on my radar.

You’re right that custom TransformStreams are not implemented either – only identity TransformStreams (the no-argument constructor). We ought to have made the constructor throw an “unimplemented” exception when passed an argument to make that clear.

Harris