CreatePersistoid taking huge amounts of CPU

Author: YCMitchCreated Mar 4, 2020Updated Jul 22, 2026

I understand this is directly related to the amount of state it needs to serialise, but I'm getting some huge lag on my app, and it's nearly always createPersistoid's fault.

throttle seems to make everything extremely unreliable (~40% of persists never get persisted), but I don't know what else I can do. I don't suppose I have any other options?

I'd perhaps envisage:

  • persisting with a service worker (so it's done on a separate thread)
  • just putting a (for example) 300ms delay on the persist, so it at least doesn't attempt to stringify my whole state while I'm doing an action. It'd surely at least make it less obvious.

Are either of these possible? Are there any other options?