Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persistentIds grows without bound? #93

Open
RandomEngy opened this issue Jan 9, 2023 · 2 comments
Open

persistentIds grows without bound? #93

RandomEngy opened this issue Jan 9, 2023 · 2 comments

Comments

@RandomEngy
Copy link

Looking at this code: https://github.com/MatthieuLemoine/electron-push-receiver/blob/master/src/index.js

It looks like persistentIds just grows with each push notification received. And each time you get a message, it's parsing out the whole list from config, creating a new array with an additional element, then re-saving it back to config. That seems like after a lot of notifications could get very slow.

Do we really need to keep every single one around?

This code in push-receiver seems to be resetting its local copy of persistentIds on a login event, and it's trying to log in every time we connect. Perhaps the right thing would be clear the persistentIds from config after a successful listen() call?

@natopedroso
Copy link

I added it in my code to solve it:

  config.persistentIds = config?.persistentIds.slice(
    config?.persistentIds?.length - 10,
    config?.persistentIds?.length,
  );

but Its odd

@RandomEngy
Copy link
Author

I've written a variant of this in Rust and I've implemented it this way:

The core library allows you to give it a list of persistent IDs to ignore on connect, but it does not store its own local copy of them.

The calling code adds the persistent IDs to a SQLite table as the messages come in. On connect, it supplies the persistent IDs and clears the SQLite table on a successful connect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants