-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
remove unhelpful logging about events without age params. #3861
Conversation
the conditional was unnecessary, the logline wasn't wrapped, and it creates literally tens of thousands of warn-level logspam on my account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am led to wonder why you are seeing events without an age
in the first place... It seems like the right fix here might be to change that rather than to keep calling a method that, to quote its documentation, "should never be used".
The presence of the conditional is odd though.
i assume they are just old events? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i assume they are just old events?
For obvious reasons, synapse injects age
at the point the event is served to you over the CSAPI. So being old wouldn't make much difference.
Having dug a little deeper, it looks like this codepath is being taken for every single typing notification. (Obligatory mention of matrix-org/matrix-spec#897). And the new fallback and logging was introduced in #3854.
Whatever else we decide to do here, we need to fix the fact that we are calling a function that "should never be used" for every single typing notification (and probably presence too). Ripping out logging that was added only two days ago is just plastering over the real problem here.
/cc @toger5
oh, also read receipts |
The intention for adding this was that I observed numerous events without age (especially state events where we relied on the age) I was hoping to confirm that this was just a rare issue I ran into because of some reason. So I indeed expected this log to almost never be called. What is the rational behind the age property? Is it acceptable to not be included in events? In what conditions is that acceptable. The fact, that this code path is always called makes sense I guess. I expected age == undefined to be undesired behaviour. |
In case it is per spec to not include the age for specific events, this (just removing the warining) indeed seems to be the right fix. The codepath still makes sense since it updates the For context this is what was changed: from:
to
so the overhead should not be severe. instead of doing one call to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not sending an age for events is acceptable and does not imply other issues removing the warning makes sense.
For call events the age is somewhat important. So another solution would be to change the condition to. this.AGE_DEPENENT_EVENTS.includes(this.eventType())
and make AGE_DEPENDANT_EVENTS
a list of event types where a missing age implies potential client issues.
(m.call.member
would be one of those events)
As I said: typing, presence, and read-receipts do not have an I really don't think we should merge this as is. Fundamentally the fact that we need to rip out this logging means that we are expecting to call code that is currently documented as "should never be used". That is extremely misleading to anyone else attempting to read the code in future. At the very least, we should update the documentation on the function to better describe the circumstances under which it is used. However, now that I look even closer, I have more questions about the original PR:
It's also worth noting, that even where |
That sounds like it would be a good filter to solve the fallback. private fallbackAge(): number {
if (!this.getTs()) {
// In case there is no origin_server_ts there is no way to do a fallback if getAge() is returning undefined
return 0;
}
if (!this.getAge()) {
logger.warn(
"`unsigned.age` for an event that has an `origing_server_ts` not available. `now - origin_server_ts` is used as a fallback. If the device clock is not correct issues might occur.",
);
}
return Math.max(Date.now() - this.getTs(), 0);
}
This sounds like it is of interest to have warnings in the console in case there is an issue. With the condition that we only even try all this if there is a
I see. The reason I was implementing it this way is to not change I agree that: Date.now() - (this.getAge() ?? this.fallbackAge())
// if getAge == undefined this equals
Date.now() - Math.max(Date.now() - this.getTs(), 0);
// which in most cases is
Date.now() - Date.now() + this.getTs() is kinda stupid... It though it makes it more readable however. The alternative would be to have a fallback localTimestamp() that would just be this.localTimestamp = this.getAge() !== undefined ? Date.now() - this.getAge() : (this.getTs() !== undefined ? this.getTs() : 0);
// this could be made more readable however:
const localTimeStampFromAge = this.getAge() !== undefined ? Date.now() - this.getAge() : undefined;
const localTimeStampFromOriginServerTs = this.getTs();
this.localTimestamp = localTimeStampFromAge ?? localTimeStampFromOriginServerTs ?? Date.now(); |
closing this PR in favour of #3870. Let's debate a correct implementation of the age fallback elsewhere. |
I perpetrated |
the conditional was unnecessary, the logline wasn't wrapped, and it creates literally tens of thousands of warn-level logspam on my account
This change is marked as an internal change (Task), so will not be included in the changelog.