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

Circular references #96

Closed
tmarzec opened this issue Sep 7, 2022 · 1 comment · Fixed by #123
Closed

Circular references #96

tmarzec opened this issue Sep 7, 2022 · 1 comment · Fixed by #123
Labels
bug Something isn't working O-Community

Comments

@tmarzec
Copy link
Contributor

tmarzec commented Sep 7, 2022

Before objects are sent over from the device, they are converted using JSON.stringify function. Because it does not support stringifying objects with cyclic references, it doesn't work here too. The current behavior is that it throws an exception and the objects are not sent over.

To reproduce this, create a schema:

{
    name: 'schemaName',
    properties: {
        prop: 'schemaName?',
    }
}

Then consider a scenario, when the object is first created (with null assigned to prop). Then the property can be assigned so that the object points to itself.

This would be fixed after solving #85.

@tmarzec tmarzec added the bug Something isn't working label Sep 7, 2022
@tmarzec
Copy link
Contributor Author

tmarzec commented Sep 7, 2022

I've changed that behavior so that it sends over an empty object in place of the one with a circular reference.

let after;
try {
after = JSON.parse(JSON.stringify(obj, replacer));
} catch (err) {
// a walkaround for #85
return {};
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working O-Community
Projects
None yet
1 participant