react-storage-hooks
react-storage-hooks copied to clipboard
infinite loop / browser hanging
Thanks for this library!
We use the useStorageState hook to persist some state to local storage while the user is typing, so we can restore it on refresh.
Recently, we received a report that when they typed, the browser locked up and had to be restarted. They're not able to reproduce it reliably, and we haven't been able to reproduce it easier.
I was able to reproduce it synthetically by adding
window.localStorage.setItem = () => {
throw new Error('my error ' + Date.now())
}
where this library goes into an infinite loop trying to handle the error (even if you're not writing to local storage). This might be a red herring, or might be the root cause.
Thoughts?
Downstream issue: https://github.com/tilt-dev/tilt/issues/4618