Contextual links only appear the first time I know this is a really specific issue, but it's a mystery that annoys me.

The contextual links menu that allows me to edit articles is only showing up the first time I view it. By this, I mean, if I refresh the page, they will no longer work. If I click the edit tab, save the node and let it return me to the node's view page, they work again. But, then I refresh, and they are broken again.

I've noticed that the focus class is appended to the article (on hover) on the page when it works, but not when it doesn't work after being refreshed. I've also noticed by debugging that in StateModel.js and VisualView.js, that toggleOpen happens twice (on the broken version -- after refresh), opening and then closing the contextual links menu. But, I can't figure out why.

The content div, which contains the html for the article &amp; contextual links, is 99% identical in bother versions with the only difference being a changed form-build-id for the comments.

The css/js files loaded on the page when it works/doesn't are nearly identical in both versions, with the only differences being a css file that does 2 unrelated things.

This is on both Firefox and Chrome.

If anyone has any ideas, it would really help me sleep at night.
I figured out that someone else has hit this error, and has contributed a patch for it:

https://www.drupal.org/node/2834346

The patch stops the Contextual Links module from adding a contextual link placeholder to the array if it's already in there.  I'm still not quite sure why there's a cookie for the contextual link (as I said in the comment above) if it's going through them and adding them anyway.  If anyone else knows more about this issue, feel free to answer.