diff --git a/indexedDb/impl/channels/implementation.go b/indexedDb/impl/channels/implementation.go index a31a49bd6390712a343936af6f57202c20d1b2f6..6ca435ef9631ea1d38e5d0b90e7577246925851b 100644 --- a/indexedDb/impl/channels/implementation.go +++ b/indexedDb/impl/channels/implementation.go @@ -417,8 +417,7 @@ func (w *wasmModel) receiveHelper( // Store message to database result, err := impl.Put(w.db, messageStoreName, messageObj) - if err != nil && !strings.Contains(err.Error(), - "at least one key does not satisfy the uniqueness requirements") { + if err != nil && !strings.Contains(err.Error(), impl.ErrUniqueConstraint) { // Only return non-unique constraint errors so that the case // below this one can be hit and handle duplicate entries properly. return 0, errors.Errorf("Unable to put Message: %+v", err) diff --git a/indexedDb/impl/dm/implementation.go b/indexedDb/impl/dm/implementation.go index 80b61d938880f15aabec96e7339914db7699beb7..6765eaa34f6cb32228800c85ae455487c663617c 100644 --- a/indexedDb/impl/dm/implementation.go +++ b/indexedDb/impl/dm/implementation.go @@ -288,7 +288,9 @@ func (w *wasmModel) receiveHelper( // Store message to database result, err := impl.Put(w.db, messageStoreName, messageObj) - if err != nil { + if err != nil && !strings.Contains(err.Error(), impl.ErrUniqueConstraint) { + // Only return non-unique constraint errors so that the case + // below this one can be hit and handle duplicate entries properly. return 0, errors.Errorf("Unable to put Message: %+v", err) } diff --git a/indexedDb/impl/utils.go b/indexedDb/impl/utils.go index 0fdb2315a1f580a675d7ebb93a257fd153056aae..93446fc101c94bbffe5c31427fa6c93b9142a3a2 100644 --- a/indexedDb/impl/utils.go +++ b/indexedDb/impl/utils.go @@ -30,6 +30,9 @@ const ( // ErrDoesNotExist is an error string for got undefined on Get operations. ErrDoesNotExist = "result is undefined" + + // ErrUniqueConstraint is an error string for failed uniqueness inserts. + ErrUniqueConstraint = "at least one key does not satisfy the uniqueness requirements" ) // NewContext builds a context for indexedDb operations.