realm-js
realm-js copied to clipboard
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
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
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
@somebody32 Thank you for your suggestion. I agree, that the current error message is a bit cryptic, and we should improve it.
@kneth also maybe not cause a native crash but a js one? The same way as schema version is validated, for example