jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.4k stars 360 forks source link

Cannot open cursor on iOS with 'nextunique' direction #71

Closed LillaFesues closed 3 years ago

LillaFesues commented 5 years ago

Issue description

If openCursor is called with the direction nextunique an exception is thrown on iOS Safari:

ERROR Error: Uncaught (in promise): UnknownError: Unable to open cursor

Additional details

  function promisifyRequestCall(obj, method, args) {
    var request;
    var p = new Promise(function(resolve, reject) {
      if (method === 'openCursor' && args[1] && args[1] === 'nextunique' ) {
        args[1] = 'next'
      }
      request = obj[method].apply(obj, args);
      promisifyRequest(request).then(resolve, reject);
    });

    p.request = request;
    return p;
  }
jakearchibald commented 3 years ago

Please create a minimal reproduction using https://codesandbox.io/ or similar and I'll take a closer look.