Page MenuHomePhabricator

PostEdit message often not showing ("Cookie has been rejected because it is already expired")
Closed, InvalidPublicBUG REPORT

Description

I'm unable to consistently reproduce this, but a number of times in the past few weeks I have submitted an edit to an article or JS page using the WikiEditor, and on the page view afterward not seen the familiar Post-edit feedback that we usually show.

The symptom I have found so far is that whenever this is the case, the console shows a warning like the following:

Cookie "incubatorwikiPostEditRevision5202237" has been rejected because it is already expired.

I note that in the cases I experienced this, I had a fast connection and the sequence of saving the edit and viewing the page took under a second. Thus any genuine edge cases about the cookie having expired already (e.g. if it takes a long time to save or render the page), should not apply. This suggests something else is going on that has caused the cookies to be set in a way that they seem to be dead on arrival.

I have also confirmed that the cookie in question is for the correct revision. For example, the above warning showed up on incubator:Purge tab after I saved an edit that woudl become revision 5202237.

Event Timeline

Can you check that your system clock is not out of sync by a few seconds? Cookie expiration uses absolute time, and these cookies have very short expirations.

I'm on macOS with the system set to automatically keep the clock in sync using Apple's NTP time.apple.com servers. I don't know how much that can be assumed to be out of sync for generally, but this is the system default and I've not changed it since it was setup four years ago.

I suspect that either the server-side clocks are somehow behind more often than usual, or (much more likely) that code execution has been re-ordered or slowed down in MediaWiki such that the cookie is drafted in PHP very early on and thus already closer to expiry by the time it arrives. That, or something regressed in its logic making it off by a few seconds more generally.

I don't know what else could cause this to be so common recently, but I suppose one way out of it is to solve T274724: Add support for "Max-Age" to WebResponse::setCookie (more reliable than "Expires").

If I recall correctly, the cookie is limited to a given title/revision (so longer lifetime would not make it appear in unrelated places), and it is also unset upon first view (so longer lifetime should not make it appear multiple times). Perhaps the expiry could be increased to encompass most cases of slow server responses, network latency, and clockskews, possibly even going up to an hour or longer (see T206804 and T196248 for clockskew data).

I feel like this isn't a fixable issue. T274724: Add support for "Max-Age" to WebResponse::setCookie (more reliable than "Expires") seems like a good idea though, and may resolve this as well, if anyone is still experiencing it.