kafka-streams icon indicating copy to clipboard operation
kafka-streams copied to clipboard

Cannot read property 'take' of null on KStream.stream$

Open zeeshanalisyed opened this issue 4 years ago • 2 comments

I am trying to close the Stream on the given object by calling close function on the instance of class KStream but receiving this error:

Cannot read property 'take' of null on KStream.stream$

I've also debugged that KStream.stream$ contains null value. https://github.com/nodefluent/kafka-streams/blob/a9a329ae07e67565d5467dac4275b88a48a1ad15/src/lib/dsl/KStream.ts#L365

import { KafkaStreams as Factory, KafkaStreamsConfig, KStream } from "kafka-streams";

interface ZStream extends KStream {
    started: boolean; 
}

let client = new Factory(Config as KafkaStreamsConfig);

let stream = client.getKStream("test");

async function Tester() {
  const started = await stream.start();
  console.log((stream as ZStream).started); // output: true
  const closed = await stream.close()
  console.log((stream as ZStream).started); // output: true which should be false
  const startagain = await stream.start();
  console.log(startagain); // output: Promise.reject => KStream is already started
  const closeagain = await stream.close(); //this part sometimes create problem
}
Tester();

zeeshanalisyed avatar Aug 25 '20 10:08 zeeshanalisyed

Hi @zeeshanalisyed thanks for the report. Are you able to provide me with a code sample of what you have so we can replicate it?

rob3000 avatar Aug 27 '20 00:08 rob3000

Hi @zeeshanalisyed thanks for the report. Are you able to provide me with a code sample of what you have so we can replicate it?

I have added the code above first of all this is produced by using client and stream as a part of the class, stream is not closed at all. but when I use class instance as a wrapper of the stream then that error is produced this is the transformed code from the real code

zeeshanalisyed avatar Aug 30 '20 07:08 zeeshanalisyed