Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application crashing in development and production #3357

Closed
ednilsoncs opened this issue Oct 20, 2020 · 2 comments
Closed

Application crashing in development and production #3357

ednilsoncs opened this issue Oct 20, 2020 · 2 comments

Comments

@ednilsoncs
Copy link

ednilsoncs commented Oct 20, 2020

Goals

Hello, I'm trying to update the database but the application is breaking

Expected Results

currently i want to update the item that is within the list of another schema

Actual Results

Currently the item is updated, but the application breaks after the item is updated, both on android and ios.

Steps to Reproduce

Burn an Evolution item with EvolutionItems, Try to update EvolutionItem multiple times

Code Sample

export const EVOLUTIONS_SCHEMA = 'evolutions';
export const EvolutionsSchema = {
  name: EVOLUTIONS_SCHEMA,
  primaryKey: 'id',
  properties: {
    id: 'string',
    title: 'string',
    type: 'int?',
    status: 'string',
    justification: 'string?',
    visit_id: 'int?',
    evolution_items: 'evolution_items[]',
    create_at: 'date?',
    model_type: 'int?',
    model_create_at: 'date?',
    attendance_id: 'int?',
  },
};
export const EVOLUTIONS_ITEM_SCHEMA = 'evolution_items';
export const EvolutionsItemSchema = {
  name: EVOLUTIONS_ITEM_SCHEMA,
  primaryKey: 'id',
  properties: {
    id: 'string',
    title: 'string',
    edited: 'bool?',
    update_at: 'date?',
    response: 'string',
  },
};
import Realm from 'realm';
import Schemas from './schemas';

export default function getRealm() {
  return Realm.open({
    deleteRealmIfMigrationNeeded: true,
    schema: Schemas,
  });
}

Method that breaks the application:

static async updateEvolutionItemDatabase({ evolutionItem }) {
    return new Promise((resolve, reject) => {
      (async () => {
        try {
          const realm = await getRealm();

          realm.write(async () => {
            const evolutionItemDatabase = realm.objectForPrimaryKey(
              'evolution_items',
              evolutionItem.id
            );
            evolutionItemDatabase.edited = true;
            evolutionItemDatabase.response = evolutionItem.response;
            evolutionItemDatabase.update_at = evolutionItem.update_at;
            resolve(evolutionItemDatabase);
          });
        } catch (err) {
          reject(err);
        }
      })();
    });
  }

Crach Report:

IOS : https://labsit-my.sharepoint.com/:w:/g/personal/ednilson_labsit_io/EXdyt0pfls1KgpxSUYygYaYBC2XDQxC8aGZQRivG3IQrew?e=LTPCw6

Android:
Build fingerprint: 'Xiaomi/laurel_sprout/laurel_sprout:10/QKQ1.190910.002/V11.0.20.0.QFQMIXM:user/release-keys'
2020-10-19 20:29:16.984 9118-9118/? A/DEBUG: Revision: '0'
2020-10-19 20:29:16.984 9118-9118/? A/DEBUG: ABI: 'arm64'
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: Timestamp: 2020-10-19 20:29:16-0300
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: pid: 7882, tid: 8499, name: mqt_js >>> com.homedoctor <<<
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: uid: 10290
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: Cause: null pointer dereference
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x0 0000000000000000 x1 0000000000000000 x2 0000000000000008 x3 0000000000000008
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x4 0000007e13cefeed x5 0000007e13cef5f8 x6 303a736e6f697475 x7 303a736e6f697475
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x8 0000000000000000 x9 0000000000000000 x10 0000000000000008 x11 4810000000000000
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x12 0000000000000034 x13 0000007de3af9f78 x14 000000003bda28fb x15 0000007df3092ee0
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x16 0000007f00a4c948 x17 0000007f009d6380 x18 0000000000000002 x19 0000007e13cf0730
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x20 0000007de3aee000 x21 0000007deaf87e40 x22 0000007deaf90f30 x23 0000000000000002
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x24 0000007e13cf0670 x25 0000000000000002 x26 0000007df2e6c4a0 x27 ffff000000000000
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: x28 ffff000000000002 x29 0000007e13cf0730
2020-10-19 20:29:17.008 9118-9118/? A/DEBUG: sp 0000007e13cef840 lr 0000007e6d4a2cc8 pc 0000007e6d4a2cc8
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: backtrace:
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #00 pc 00000000001d9cc8 /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #1 pc 00000000001d9b60 /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #2 pc 00000000001d57e4 /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #3 pc 00000000001d4784 /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #4 pc 00000000001d4210 /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #5 pc 00000000001d2bac /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #6 pc 000000000028ebbc /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #7 pc 0000000000238388 /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/librealmreact.so (BuildId: d4f57dbab37cc023c479d884a5a191b0cfb80d98)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #8 pc 00000000000b3b3c /data/app/com.homedoctor-amV2euTeR7EJBeP4f3KYWw==/lib/arm64/libjsc.so (long JSC::APICallbackFunction::callJSC::JSCallbackFunction(JSC::ExecState*)+340)
2020-10-19 20:29:17.570 9118-9118/? A/DEBUG: #9 pc 0000000000079ec8 anonymous:7df6aaf000

Version of Realm and Tooling

  • Realm JS SDK Version: 6.1.4
  • Node or React Native:0.63.2
  • Client OS & Version: Android 10 and iOS 14
  • Which debugger for React Native: Android 10
@kneth
Copy link
Contributor

kneth commented Oct 26, 2020

In order for be ACID compliant, Realm.write() is a synchronous method. Try to remove async from realm.write(async () ....

@ednilsoncs
Copy link
Author

Thank you very much for the note, after the update and correction you recommended, I was unable to replicate the error

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants