File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -111,13 +111,20 @@ func ConvertReadableStreamToReadCloser(stream js.Value) io.ReadCloser {
111111// - ReadableStream: https://developer.mozilla.org/docs/Web/API/ReadableStream
112112// - This implementation is based on: https://deno.land/std@0.139.0/streams/conversion.ts#L230
113113type readerToReadableStream struct {
114- reader io.ReadCloser
115- chunkBuf []byte
114+ initialized bool
115+ reader io.ReadCloser
116+ chunkBuf []byte
116117}
117118
118119// Pull implements ReadableStream's pull method.
119120// - https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream#pull
120121func (rs * readerToReadableStream ) Pull (controller js.Value ) error {
122+ if ! rs .initialized {
123+ ua := NewUint8Array (0 )
124+ controller .Call ("enqueue" , ua )
125+ rs .initialized = true
126+ return nil
127+ }
121128 n , err := rs .reader .Read (rs .chunkBuf )
122129 if n != 0 {
123130 ua := NewUint8Array (n )
You can’t perform that action at this time.
0 commit comments