GithubHelp home page GithubHelp logo

Comments (7)

Mr0grog avatar Mr0grog commented on August 15, 2024

Guess this is kind of related to stellar-deprecated/horizon#119, just from the client perspective. Didn’t see that one before I posted here 😬

from js-stellar-sdk.

shredding avatar shredding commented on August 15, 2024

I have this error as well, does it mean I can ignore it?

from js-stellar-sdk.

gjermundgaraba avatar gjermundgaraba commented on August 15, 2024

Could this be worth fixing? I have the same problem :P

from js-stellar-sdk.

tomquisel avatar tomquisel commented on August 15, 2024

Should be fixed by stellar/go#884, which will be released this week in Horizon v0.17. Closing. Please re-open if you continue having problems.

from js-stellar-sdk.

cballou avatar cballou commented on August 15, 2024

I believe this may need to be re-opened on the js-stellar-sdk side (things look good from my stellar/go patch).

As far as I'm aware in the specification of JS and SSE, the error event should be of type Event and not MessageEvent. I still see no appropriate message bubbling on the JS side, so I would surmise this may be the underlying culprit.

You can see the documented differences here:

Specifically, if you take a look at call_builder.ts, you'll see how the onerror callback event gets triggered via error as MessageEvent:

export interface EventSourceOptions<T> {
  onmessage?: (value: T) => void;
  onerror?: (event: MessageEvent) => void;
  reconnectTimeout?: number;
}

// ... and further down ...

    const createEventSource = () => {
      try {
        es = new EventSource(this.url.toString());
      } catch (err) {
        if (options.onerror) {
          options.onerror(err);
        }
      }

      createTimeout();

      if (es) {
        es.onmessage = (message) => {
          const result = message.data
            ? this._parseRecord(JSON.parse(message.data))
            : message;
          if (result.paging_token) {
            this.url.setQuery("cursor", result.paging_token);
          }
          clearTimeout(timeout);
          createTimeout();
          if (typeof options.onmessage !== "undefined") {
            options.onmessage(result);
          }
        };

        es.onerror = (error) => {
          if (options.onerror) {
            options.onerror(error as MessageEvent);
          }
        };
      }

      return es;
    };

I'm not wholeheartedly sure which is the appropriate Event interface here to bubble the pertinent information to the user, but it would definitely be helpful to finally get this right and put the nail in the coffin.

from js-stellar-sdk.

tomquisel avatar tomquisel commented on August 15, 2024

@abuiles what are you thoughts on the best approach here?

from js-stellar-sdk.

dolcalmi avatar dolcalmi commented on August 15, 2024

seems to be the limit configuration in Horizon: https://github.com/stellar/go/blob/master/services/horizon/internal/handler.go (search handler.streamHandler.ServeStream)

a temporary "fix"/solution would be to add the limit param (max 200) that will give us "more time" before the connection is closed

curl -H "Accept: text/event-stream" "https://horizon.stellar.org/transactions?order=asc&cursor=now&X-Client-Name=js-stellar-sdk&X-Client-Version=3.3.0&limit=200"

from js-stellar-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.