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

Writing an invalid Date object causes native crash

      How frequently does the bug occur?

      All the time

      Description

      If you have a schema with a date field and you would try to save new Date(NaN) into it, Realm would crash. In this case, it is an obvious error from the user, but shouldn't it be handled more gracefully?

      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
      libc++abi: terminating with uncaught exception of type std::invalid_argument: Value 'Invalid Date' not convertible to a number.
      

      Can you reproduce the bug?

      Yes, always

      Reproduction Steps

      Unable to find source-code formatter for language: ts. 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
      realm.write(() => {
        realm.create('Task', {date: new Date(NaN)}, 'all');
      });
      

      Version

      10.19.5

      What SDK flavour are you using?

      Local Database only

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      iOS 15.6

      Build environment

      No response

      Cocoapods version

      No response

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

              Created:
              Updated: