kuzzleio / sdk-javascript

Kuzzle Javascript SDK. High level library including multi-protocol support, offline resiliency, realtime data and more
http://docs.kuzzle.io/sdk/js/7
Apache License 2.0
39 stars 15 forks source link

SDK 6 Http Protocol cause JS engine crash with connect on offline #418

Closed ScreamZ closed 5 years ago

ScreamZ commented 5 years ago

I'm building an offline app as PWA.

Doing this while switching network offline or stopping kuzzle server

const kuzzle = new Kuzzle(new Http(process.env.API_HOST));

try {
   await kuzzle.connect();
 } catch (e) {
   console.log(e);
 }

results in :7512/:1 GET http://localhost:7512/ net::ERR_INTERNET_DISCONNECTED

will crash the client which is unable to catch the following error thrown by connect.

Related

Aschen commented 5 years ago

Hi @ScreamZ ,

Thanks you for your feedback! This will be fixed by this PR: https://github.com/kuzzleio/sdk-javascript/pull/420 (explanation are in the PR description)

ScreamZ commented 5 years ago

Closed, resolved by https://github.com/kuzzleio/sdk-javascript/pull/420

Kafigueiredo commented 5 years ago

@Aschen when i'm offline, i want to catch an error. This code never resolve: i can't catch this error.

  try {
    await kuzzle.document.create("xxx", "xxx", xxx);
  } catch (error) {
    console.log(error);
  }

Chrome console return me :

OPTIONS http://localhost:7512/xxx/xxx/_create net::ERR_INTERNET_DISCONNECTED
scottinet commented 5 years ago

Hi @Kafigueiredo ,

There was a promise-leak occuring on network disconnection, this should be resolved by https://github.com/kuzzleio/sdk-javascript/pull/427

(not yet released on npm)