Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-1519

Iterating over results: random error `undefined is not an object (evaluating 'v.next')`

      Description

      At some point all code running queries start failing with the following error: undefined is not an object (evaluating 'v.next'). I'm sorry I don't have a stack trace, the the user that sent this log basically got this error from everywhere a realm query was looped over, and ultimately ended up in a hard crash: EXC_BAD_ACCESS: Attempted to dereference garbage pointer 0x1c.

      I got error logs from 3 different places in the app that run queries asynchronously / with timers or in a loop. They all happened at almost the same time while looping through collections.

      Code example that threw the error:

      // Query 1
      let res = realm.objects('QueueItem').filtered(`groupId=${groupId}`);
      
      res = res
        .sorted([
          ['locked', false],
          ['error', false],
          ['mobile', true],
          ['priority', false],
          ['added', false],
        ])
        .slice(0, count)
        .map((obj) => {
          let res = toPlainObject(obj);
          return res;
        });
      
      return res;
      
      
      // query 2 in a completely different location in the code
      let items = realm
            .objects('GalleryItem')
            .filtered(`added <= ${timestamp} and webId != null`);
      for (let ele of items)....
      
      
      // Helper func
      export function toPlainObject(realmObject, schemaProperties) {
        let res = {};
        for (let k of Object.keys(schemaProperties)) {
          res[k] = realmObject[k];
        }
        return res;
      }
      

      Stacktrace & log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Only the error message is available as our logging handles the unhandled exception and only logs the message.
      

      Can you reproduce a bug?

      Not yet

      Reproduction Steps

      Unknown. Just filtering, querying and looping.

      Version

      10.20.0-alpha.2

      What SDK flavour are you using?

      Local Database only

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      iOS 14.4.2 (iPhone XR)

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: