The other existing question didn't work for me. (How to close a stream event?)

I set up a class to handle and switch streams. In the constructor, I define and initialize the stream this way:

function RequestStream() {

    this.server = new StellarSdk.Server('https://horizon.stellar.org');

    this.stream = this.server.transactions()
      onmessage: function (message) {
        console.log("initial transactions stream");
        tripManager.addTrip(new Trip(node2.position));

My instance variable stream should contain the function close to close the stream. Using a prototype, I have several functions to switch the stream. I want to close the current stream through the instance variable before creating a new one and setting it to the same instance variable.

RequestStream.prototype = {
   constructor: RequestStream,
      payments:function ()  {
        this.stream = this.server.payments() // + rest of stream init

I receive "TypeError: this.stream.close is not a function" upon trying to close the stream. Printing out this.stream gives an object with no apparent useful info. Can provide more detail if needed.

1 Answer 1


In your case this.stream after initialization should contain a destructor function. Try to call this.stream() instead of this.stream.close().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.