resgateio/resgate

Multiple responses to get request

Closed this issue · 1 comments

Issue

In case the access request is delayed when getting a resource with resource references, it is possible that the client's get/subscribe request will get two responses.

This happens when linked resources are loaded before the subscription.OnReady(...) call is made from wsConn.go.

Example

12:02:10 [Main] Starting server
12:02:10 [Main] Connecting to messaging system
12:02:10 [NATS] <=S system
12:02:10 [NATS] <=S conn.bj5c08l8smgjbc0l8ajg
12:02:10 [bj5c08l8smgjbc0l8ajg] Connected
12:02:10 [bj5c08l8smgjbc0l8ajg] --> {"method":"subscribe.test.model.parent","id":1}
12:02:10 [NATS] <=S event.test.model.parent
12:02:10 [NATS] <== access.test.model.parent: {"token":null,"cid":"bj5c08l8smgjbc0l8ajg"}
12:02:10 [NATS] <== get.test.model.parent: {}
12:02:10 [NATS] ==> get.test.model.parent: {"result":{"model":{"name":"parent","child":{"rid":"test.model"}}}}
12:02:10 [NATS] <=S event.test.model
12:02:10 [NATS] <== get.test.model: {}
12:02:10 [NATS] ==> get.test.model: {"result":{"model":{"string":"foo","int":42,"bool":true,"null":null}}}
12:02:10 [NATS] ==> access.test.model.parent: {"result":{"get":true}}
12:02:10 [bj5c08l8smgjbc0l8ajg] <-- {"result":{"models":{"test.model":{"bool":true,"int":42,"null":null,"string":"foo"},"test.model.parent":{"child":{"rid":"test.model"},"name":"parent"}}},"id":1}
12:02:10 [bj5c08l8smgjbc0l8ajg] <-- {"result":{},"id":1}

Solved in #85