Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Fix/circular #67

Closed
wants to merge 3 commits into from
Closed

Fix/circular #67

wants to merge 3 commits into from

Conversation

ProbablePrime
Copy link
Contributor

This resolves #37

Simply replaces circular references with nothing within our socket handling logic. This is handy for some issues i've seen in 3rd party projects who are not aware of some of the circular references our internal state store has.

I wish i'd saved the original example but cannot locate it.

@ProbablePrime ProbablePrime requested review from SimonSchick and connor4312 and removed request for SimonSchick June 8, 2017 16:53
@@ -339,7 +341,8 @@ export class InteractiveSocket extends EventEmitter {
}

private sendRaw(packet: any) {
const data = JSON.stringify(packet);
// Replace circular references with nothing.
const data = stringify(packet, null, 0, () => {/** */});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only recursive data structure that is specified on the protocol is the memory warning structure the server sends. Sending any recursive packet is going to be invalid. I think that throwing an error is the right thing to do here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some people are literally doing something like:

control.text='blah'
contro.progress = 1.0

client.updateControls({sceneID:'blah',controls:[control]);

Which leads to the circular as control has a ref to scene.

Should we instead add a toJSON to each tree area that strips out circulars?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make sense!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright doing that. woot

@ProbablePrime
Copy link
Contributor Author

Will re-open with toJSON'ing sometime later

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Circular References
2 participants