Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

fillMessageKeys: allow for SessionCipher creator to specify limit #29

Merged
merged 1 commit into from
Aug 4, 2017

Conversation

scottnonnenberg
Copy link
Contributor

People leave their laptops closed for weeks at a time, and get this error, since their other devices are sending messages to it constantly:

"Too many message keys for chain"

And it seems to be really hard to fix once you're in this state. Sync messages no longer show up from the device that got into this state.

@liliakai
Copy link
Contributor

Do we have a theory on why this seems specific to sync messages?

Copy link
Contributor

@liliakai liliakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be best to do this without introducing cross-repo dependencies. This change would create errors for anyone who happens to be using this library outside Signal Desktop.

Maybe we could consider simply raising this limit by default or adding it as a configurable option to SessionCipher's constructor?

@@ -240,7 +240,10 @@ SessionCipher.prototype = {
});
},
fillMessageKeys: function(chain, counter) {
if (Object.keys(chain.messageKeys).length >= 1000) {
var ourNumber = textsecure.storage.user.getNumber();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textsecure.storage is not part of this repo and we shouldn't depend on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How else might a user of this library tell us who the current user is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this library should care about a "current user" concept, as it generally operates on a per-device level. I would just make the limit an option on SessionCipher, then the application can decide:

new SessionCipher(store, address); // limit 1000
new SessionCipher(store, address, isOurNumber ? { fillMessageKeysLimit: 5000 }); // limit 5000
new SessionCipher(store, address, isOurNumber ? { fillMessageKeysLimit: false }); // no limit

@scottnonnenberg scottnonnenberg changed the base branch from master to trust-store-changes August 4, 2017 16:38
@scottnonnenberg scottnonnenberg changed the title fillMessageKeys: only check for >1000 if message not from yourself fillMessageKeys: allow for SessionCipher creator to specify limit Aug 4, 2017
@scottnonnenberg
Copy link
Contributor Author

This PR has been updated with @liliakai's recommendations. If options.messageKeysLimit is provided and falsey, then we don't apply any limit at all. This can be used to set no limit for communications to and from your own devices.

If options.messageKeysLimit is provided by falsey, then we don't apply
any limit at all. This can be used to set no limit for communications
from your own devices.

Why would you want that? People leave their laptops closed for weeks at
a time and get this error, since their other devices are sending
messages to it constantly:

"Too many message keys for chain"

And it seems to be really hard to fix once you're in this state. Sync
messages no longer show up from the device that got into this state.

FREEBIE
@michaelkirk
Copy link

michaelkirk commented Aug 4, 2017

Do we have a theory on why this seems specific to sync messages?

My understanding is that this most frequently affects sync messages because if you have n conversations with k messages, each of those chains will be only k long, but the chain with your synced device will be n*k.

Right?

Copy link

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

My understanding is that if the device is offline for "a long enough time" we'll also see message loss due to the server queue being full. But I think this is a step in the right direction. It seems reasonable that sync queues/chains could get special treatment.

@scottnonnenberg
Copy link
Contributor Author

Exactly. You communicate far, far more with your own devices than anyone else.

@scottnonnenberg scottnonnenberg merged commit 3d72df7 into trust-store-changes Aug 4, 2017
@scottnonnenberg scottnonnenberg deleted the unlimited-for-yourself branch August 4, 2017 18:26
elsehow added a commit to elsehow/signal-protocol that referenced this pull request Aug 4, 2017
scottnonnenberg added a commit that referenced this pull request Nov 21, 2017
Quite a few changes to reflect new behavior around identity keys rolled
out in the Signal apps in June 2017:
  - We always trust a new identity key when receiving messages
  - We have a few requirements for trust when sending messages:
    1) it can't have changed very recently
    2) if the previous identity key had been verified by the user, the
       user needs to explicitly approve a new identity key

Expose ability to delete all existing sessions - for proper reset (#35)

Allow caller to provide fillMessageKeys limit - allowing customization
  of the maxiumum number of one-sided messages in a conversation (#29)

Dev:
  - A number of changes to make the branch build in CI, add badge, etc.

Note: we appear to have some unreliability during our Firefox 34 builds
on Sauce. A little less than half the time the test fails with an out of
memory error.
@signalapp signalapp deleted a comment from 6531076392 Jan 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants