dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.68k stars 642 forks source link

Windows10 + Firefox or chrome + Error #608

Closed vousys closed 7 years ago

vousys commented 7 years ago

Hi! this error started happening recently, and only over Windows 10 with chrome v61 or firefox v56 (latest stable)

bs_win10_firefox_56 0

The database is created Ok, as you can see in the console. The problem is when I try to add a record here:

          db.transaction('rw', db.grupo_comentarios, async() => {

                // Make sure we have something in DB: // Agrego
              if ((await db.grupo_comentarios.where('post_uuid').equals(  _self.data.uuid   ).count()) === 0) {
                  let id = await db.grupo_comentarios.add({post_uuid: _self.data.uuid , ultimo: _self.data.comentarios.ultimo_nuevos });
              }else{ // update
                   await db.grupo_comentarios.where('post_uuid').equals(  _self.data.uuid   )
                          .modify({ultimo: _self.data.comentarios.ultimo_nuevos });

              }
          }).catch(e => {
              alert(e.stack || e);
          });

and this is the way I use to open the database:

           // CREO LA INDEXDB
           _self.db = new Dexie("my_db");
           _self.db.version(1).stores({
              grupo_comentarios: '++id,ultimo, primero,post_uuid'
           });
           _self.db.version(2).stores({
              grupo_comentarios: '++id,ultimo, primero,post_uuid',
              carpooling_grupo_comentarios : '++id,ultimo, primero,post_uuid',
           }).upgrade(function () {

            });

I'm using dexie - Version 2.0.0-beta.10, Tue Jan 31 2017

I try it with an empty database and also with a database that previously had had records. and Is the same problem, but remember: only in windows10 ¿Can you help me please?

dfahlander commented 7 years ago

I don't think the problem lies in Windows 10. Especially as your problem appears on chrome and firefox on windows 10. I rather think there is some other error on the device but I can't debug from the info in this issue. You said you've tried to delete the database and start over. Strange that it doesn't fix the problem. Are you seeing any errors in the console?

Maybe you have older versions of chrome and firefox on your windows machine that doesnt support async await?

vousys commented 7 years ago

As I can see on browserstack is they latest stable versión of them. I'm under Mac and this Is a mobile/webapp that works fine everywhere, Even under internet Explorer 16 😱 as I could debug. Can I make a transaction without async?

El 3 nov. 2017 04:42, "David Fahlander" notifications@github.com escribió:

I don't think the problem lies in Windows 10. Especially as your problem appears on chrome and firefox on windows 10. I rather think there is some other error on the device but I can't debug from the info in this issue. You said you've tried to delete the database and start over. Strange that it doesn't fix the problem. Are you seeing any errors in the console?

Maybe you have older versions of chrome and firefox on your windows machine that doesnt support async await?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dfahlander/Dexie.js/issues/608#issuecomment-341638081, or mute the thread https://github.com/notifications/unsubscribe-auth/AMODpYWazpmNC4seUoyq7-fgSSWITq6Oks5sysPdgaJpZM4QQjek .

nponiros commented 7 years ago

You could try this:

db.transaction('rw', db.grupo_comentarios, () => {
  const promise = db.grupo_comentarios.where('post_uuid').equals(  _self.data.uuid   ).count();
  promise.then((count) => {
    if(count === 0) {
      return db.grupo_comentarios.add({post_uuid: _self.data.uuid , ultimo: _self.data.comentarios.ultimo_nuevos });
    } else {
      return db.grupo_comentarios.where('post_uuid').equals(  _self.data.uuid   )
                          .modify({ultimo: _self.data.comentarios.ultimo_nuevos })
    }
  })
}).catch(e => {
  alert(e.stack || e);
});
vousys commented 7 years ago

Thanks Nikolas!! this has fixed the error! 👍 👍 👍 👍