-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: None
-
Component/s: None
-
None
-
SDK FY21-Q3, SDK FY21-Q3.
-
3121
The Node SDK segfaults rather than throwing a useful/catchable error if you try to create an embedded object directly rather than from a parent object.
const Realm = require("realm"); const config = { path: "embeddedObjects", schema: [{ name: "Address", embedded: true, properties: { street: "string", city: "string" }, }, { name: "Contact", properties: { name: "string", address: "Address", }, }], } async function main() { Realm.deleteFile(config) const realm = await Realm.open(config); // This write succeeds, as expected! realm.write(() => { realm.create("Contact", { name: "Joe Jasper", address: { street: "123 Main Street", city: "New York City" } }) }) // This write throws a useful error: "Error: Object type 'Foo' not found in schema."" realm.write(() => { realm.create("Foo", { bar: 42 }) }) // Address is an embedded object type, so this write should not work. // However, the call segfaults rather than throwing a useful error. // e.g. "Error: Object type 'Address' is embeddable, so it cannot be directly created." realm.write(() => { realm.create("Address", { street: "123 Main Street", city: "New York City" }) }) realm.close() return process.exit() } main().catch(err => { console.error(err) })