lukejacksonn/perflink

JSON parse error

FredKSchott opened this issue · 4 comments

Feel free to close this if it's out of scope, but I ran into a strange bug in development where I already had localstorage values stored for previous development on localhost. An existing entry in localstorage had the value "ERROR", causing this line to fail.

Object.entries(localStorage).map(([k, v]) => [k, JSON.parse(v)])
// Error: Couldn't parse `JSON.parse('ERROR')`

Oh ouch.. I hadn't considered that edge case 😅 I have take a rather brutal approach to storage. Might re-address at some point or try filter out irrelevant keys. Will leave open to remind me!

I have the same error. I don't remember if I visited this website before, maybe I did. Also I'm not sure, if my extensions, that have access to the website, didn't set their own fields in the local storage.
My local storage looks like this:

{
  randid: "rd3a6q82gqkje4c49qfc7o8babn",
  length: 1
}

The resulting syntax error blocks from rendering anything at all, the website is completely blank.

@pepkin88 your issue is a little different to Fred's. His happened on localhost where there was some stuff in localStorage (probably from another project). Yours is happening because you have a chrome extension that injects into every pages localStorage, even in production.

I believe the extension in question is this one https://chrome.google.com/webstore/detail/pop-up-blocker-for-chrome/bkkbcggnhapdmkeljlodobbkopceiche

All I can suggest for now is suggest to disable that extension and clear the localStorage on perf.link domain. Until I get around to fixing it. It wasn't defensively coded tbh!

I'm pretty confident this is fixed since #31 so going to close here. Thanks for the report and lmk if there are any further issues!