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

v0.5.0 alpha randomly stops syncing #110

Closed
Avigant opened this issue Jan 19, 2019 · 10 comments
Closed

v0.5.0 alpha randomly stops syncing #110

Avigant opened this issue Jan 19, 2019 · 10 comments
Labels
type: bug Something happens that shouldn't happen

Comments

@Avigant
Copy link

Avigant commented Jan 19, 2019

I have absolutely no idea how to reproduce this, but it is happening once or twice an hour. Serving never stops, only syncing. The plugin shows that Rojo is no longer connected. I am on Windows 10.

@LPGhatguy
Copy link
Contributor

If you reconnect the client, does syncing work again? Is there anything in your output window?

When this happens, can you visit http://localhost:34872/api/rojo (with whatever port number you're using) in a browser and see what the response is?

There are two things in Rojo that can go wrong to stop syncing:

  • The server code might hit an unexpected error, which stops it from accessing any of its own data (you'll see "mutex poisoned" or such in the output)
  • The plugin might trip trying to apply properties to Roblox objects, or might receive an unexpected response and throw. In this case, the session will terminate and output the issue to the console!

@LPGhatguy LPGhatguy added the type: bug Something happens that shouldn't happen label Jan 19, 2019
@Avigant
Copy link
Author

Avigant commented Jan 20, 2019

Syncing works as soon as I hit the "connect" button on the plugin again. Nothing happens in my Output. I should've specified this.

I will visit that at the next time I encounter this and report back.

@Avigant
Copy link
Author

Avigant commented Jan 20, 2019

01:22:41.444 - [Rojo-Warn] Plugin_1997686364.Rojo.Plugin.ApiContext:133: attempt to call method 'json' (a nil value)

I was wrong - there is actually output. This is the warning I get.

The raw JSON of the link you told me to visit:

{"sessionId":"da43d69b-134f-480e-907a-4dc6648dcd57","serverVersion":"0.5.0-alpha.0","protocolVersion":2,"expectedPlaceIds":[2764381117],"rootInstanceId":"38776c9b-6565-42b7-85de-eb865680cc12"}

@LPGhatguy
Copy link
Contributor

Okay, that issue in the output window helps a lot, I should be able to track that down this week!

@Validark
Copy link
Contributor

Validark commented Jan 22, 2019

When it happens, it will quickly call ApiContext:retrieveMessages()'s andThen method twice.

The first one seems normal

{body = "{"sessionId":"9bf75c92-4e56-499d-8242-8e2b5511cc37","messageCursor":4,"messages":[{"added":[],"removed":[],"updated":["91f67966-8457-4c89-8a0b-63cb9be819da"]}]}", code = 200, headers = {["content-length"] = "160", ["content-type"] = "application/json", date = "Tue, 22 Jan 2019 21:06:11 GMT", server = "tiny-http (Rust)"}} <- {__index = [self], __tostring = function, fromRobloxResponse = function, isSuccess = function, json = function}

Then afterwards, it will call it with a table that looks like this:

{{added = {}, removed = {}, updated = {"91f67966-8457-4c89-8a0b-63cb9be819da"}}}

This will cause the warning, because it lacks a json function.

@LPGhatguy
Copy link
Contributor

I refactored a lot of the relevant code in the plugin recently, can you see if the problem is still happening in the latest alpha?

@Validark
Copy link
Contributor

I am curious how that random table somehow leaked into the Promise. How was it even possible? Have any theories?

@LPGhatguy
Copy link
Contributor

I figured it out specifically today and fixed it. It was pretty simple!

In ApiContext:retrieveMessages(), I was trying to respond to a timeout by restarting listening for messages again:

https://github.com/LPGhatguy/rojo/blob/4516df5aac4c9296ba30256d5437e9ffe06564f9/plugin/src/ApiContext.lua#L140-L163

Note that on line 146, I'm calling retrieveMessages again. retrieveMessages doesn't return an HttpResponse, it returns a table that looks like the second one you reported!

Basically, if there was a timeout (and thus another retrieveMessages call) and that call did not time out, those changes would be applied followed immediately by an error.

The fix was straightforward. I made a new function to do the recursive timeout nonsense and I just invoke it from within retrieveMessages now:

https://github.com/LPGhatguy/rojo/blob/aa243d1b8af49731e9977dd6f0413652f0b5dd07/plugin/src/ApiContext.lua#L140-L167

@Validark
Copy link
Contributor

Good work! Thanks for explaining it to me. I understand why it failed now. I was scared there might have been a problem with Promise.

@LPGhatguy
Copy link
Contributor

I was actually pretty worried that promises would be broken in some obscure way too! 😅

Dekkonot pushed a commit to UpliftGames/rojo that referenced this issue Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something happens that shouldn't happen
Projects
None yet
Development

No branches or pull requests

3 participants