jakearchibald / idb-keyval

A super-simple-small promise-based keyval store implemented with IndexedDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about the safety of the "entries" method

fabiospampinato opened this issue · comments

I see the entries method basically requests both keys and values and then merges them together:

return Promise.all([
    promisifyRequest(store.getAllKeys()),
    promisifyRequest(store.getAll()),
]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));

This looks potentially problematic to me, but I don't know enough about IndexedDB to be sure, hence the question: can this ever return an incorrect result? Like is it possible that after the key for an object is returned, but before the value for that object is returned, the key gets deleted so that one ends up with the array of keys and the array of values having different lengths, which would potentially completely mess up the database depending on how those entires are manipulated?