strongloop / loopback

LoopBack makes it easy to build modern applications that require complex integrations.
http://loopback.io
Other
13.22k stars 1.2k forks source link

Create change stream causes issues #4027

Closed imike57 closed 5 years ago

imike57 commented 6 years ago

Hi,

I encounter some problem with the use of the change-stream API, the data is loaded but not after several access to the page that performs the requests.

Description

I make requests and subscribe to two collections:


    // Get collection items
    this.categoriesTree$ = this.categoryTreeApi.findOne({ "order": "created DESC" }).subscribe((categoryTree: CategoryTree)=>{
      this.categoryTree = categoryTree.value;

      // Inspect collection change
      this.categoriesTreeChange$ = this.categoryTreeApi.createChangeStream().subscribe((majCategoryTree: any) => {
        console.log(majCategoryTree);

      }, (err: any) => {
        this.notificationsService.error('Oops ! ', 'An error occurred while listening to the changestream of categoryTreeApi : ' + err.message);
        console.error(err)
      });

    }, (err: any) => {
      this.notificationsService.error('Oops ! ', 'The Tree has not been loaded : ' + err.message);
      console.error(err)
    });

I unsubscibe to theses subscription while onDestroy();

I got my content during the first page loading. Everything is well loaded. image

Then I just change of page to "Products" and back to "Categories" page. (Products page is empty for now)

image

It still work well...

But if I did it 2 times more, it no more working...

image

The request is still pending

image

No error in the console during some seconds or minutes sometime then : image

I'm sure it's related to the createchangestream because if I remove these subscription it work well, but I need it to update some content in realtime..

I subscribe to the change subscription only when my main category subscription is ready. So it seems that it is the subscription to the changes of the previous step that cause issue. However, I am unsubscribing to this subscription to the event onDestroy (), so should not I be killed? Yet it seem still there image

Expected result

Be able to make connections correctly at any time after a page change when subscriptions to changestream have been previously made.

Additional information

I use loopback 3.x

\lb-server> lb --version
4.2.0 (generator-loopback@5.9.2 loopback-workspace@4.3.1)

SDK builder https://github.com/mean-expert-official/loopback-sdk-builder Angular 6

Desgaibou commented 5 years ago

I have the same issue. Any suggestion? Thanks

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.