diff --git a/ts/src/transports/fetch.ts b/ts/src/transports/fetch.ts index 9172c2e2..6de44296 100644 --- a/ts/src/transports/fetch.ts +++ b/ts/src/transports/fetch.ts @@ -22,14 +22,15 @@ class Fetch implements Transport { this.options = transportOptions; } - pump(readerArg: ReadableStreamReader, res: Response): Promise { + pump(readerArg: ReadableStreamReader, res: Response) { this.reader = readerArg; if (this.cancelled) { // If the request was cancelled before the first pump then cancel it here this.options.debug && debug("Fetch.pump.cancel at first pump"); - return this.reader.cancel(); + this.reader.cancel(); + return; } - return this.reader.read() + this.reader.read() .then((result: { done: boolean, value: Uint8Array }) => { if (result.done) { detach(() => { @@ -40,7 +41,8 @@ class Fetch implements Transport { detach(() => { this.options.onChunk(result.value); }); - return this.pump(this.reader, res); + this.pump(this.reader, res); + return; }); } @@ -56,7 +58,8 @@ class Fetch implements Transport { this.options.onHeaders(new Metadata(res.headers as any), res.status); }); if (res.body) { - return this.pump(res.body.getReader(), res) + this.pump(res.body.getReader(), res) + return; } return res; }).catch(err => {