I suspect this should be checking against `undefined` rather than `null`.  `type` is either `"save"` or `"cache"` according to the docs, and we don't explicitly set those anywhere that I can see.

Since in the case that it's not defined it simply attempts to call again in a little bit, I'd assume that we're waiting for some other code to init the database, so `undefined` is the most likely value; if in doubt, we could simply leave it as is.