amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.03k stars 1.16k forks source link

gun.once in gun.on can an infinit loop on certain conditions #1242

Open CodingBitsDev opened 2 years ago

CodingBitsDev commented 2 years ago

In my gun.user() three there is a node at root called "gun-calendar". The node currently has the following state

{"calendars":{"0f49797c-8ff1-42f2-8d01-4b2e15332784":null,"1b59d9fc-33cb-4df3-a6ee-1bbda3358081":null,"38f219cc-5108-498e-8834-0a24d48de4c7":null,"54615a14-d9fb-4378-a7fd-3d02924aa069":null,"6ed3b50a-efb2-489e-a588-554acbce6968":null,"72e7d3a4-f917-4fa8-9469-2e1852ec5fa5":null,"7f6c4be5-64db-485e-8957-485289f6d41c":null,"86dd2756-4079-4223-a614-8713bc81333b":null,"88fe2a4b-1401-46c3-b74b-3c6e0f860ddb":null,"9a5762c8-9f02-4d23-bd6e-bce415da2f95":null,"9fb78a4e-96e7-43d0-8858-1a128b9166e3":null,"be90d60a-489e-4ec6-b523-b4c3c47b1705":{"key":"SEA{"ct":"H8ZA5aNFOhN103s4fFiAq8p+gaIMMeGn5OyfIZA3N4O2xvdJ+LPnbJuDIskzvMUPFK1IMOFYt0agiVpayiZKOsztjxqZmbKV7sJ6YfJKNtpGiP3/2XHyRdlEBvs3Defq6lGtslCFHL8HU1EUExTb/nejkvVe/KJeYV3J/KHzuuWVsb81ofyb6ImIOLGMna1XDdELFtWxk2Bg8a2p3sgtE8+GEhlFCsu7TjAJaRjXvmAWRu6U8P62tLbl+CI8ByVV8QPXE9Rb5mOREDLAIlea8SSUti3sNn7/sztfmSzGi/Og8XG7IYqYbEXjOtkHKon6ZNg9umtYxmWnz9Ck9ZUy7QRtJpQyR5Fvg3DDETImn1XuEAH3sZQFIpIyjECQ4pTsFPgn6dQ0nUtreoaK1kzUi8Hvk2anTIVVQs0QPHE=","iv":"d4SUl5sqaJISJJsivFpS","s":"92o6hgqhK9+2"}","months":{"1651363200000":"SEA{"ct":"36sSN1KUuR8IQW9js2MqFBjs","iv":"Cu5ZkDOb/echD3+LesJL","s":"463Ks6HGjtXr"}"},"owner":"Nils"},"c321a1be-5cd8-4c32-adb0-15000bb03ff1":null},"auth_pin":"SEA{"ct":"ZADZ3K8xUrodMbE0jC6zdpI=","iv":"Adw4sm4L+Q4FH8oyLcsl","s":"lIfGmqRmO/K9"}","name":"Nils"}'

When running

node = gun.user().get("gun-calendar").get("calendars");
node.on(() => { console.log("loop"); node.get("be90d60a-489e-4ec6-b523-b4c3c47b1705").once(console.log))

I get an infinite loop. I havn't managed to recreate this with a simpeler state than this so far.

@amark asked me to create an Issue about it. Here it is. In my case this is not to severe because I can ensure to only call the listener once but I can Imagine cases where this can cause a biger problem.

That said. Thanks for creating and maintaining on such a great library like gunjs.