jca Posted November 9, 2018 Share Posted November 9, 2018 (edited) This isn’t really a bug more of a question about how this could happen. For example - I have a script, at the start of the loop there’s a function that checks if the account is logged in. I have a login handler event that I execute in my onStart, in the constructor I setAsync(). In the execute() method I return 5000; if the account is logged in, if not I log the account in without pausing the script executor (as the loop is checking the opposite condition). 9/10 this login handler runs without interupping the main thread. Occasionaly it runs, the account logs in but the onLoop running on the main thread stops. No errors in the log, nothing. Anyone ever experienced this before? Edited November 9, 2018 by jca Quote Link to comment Share on other sites More sharing options...
liverare Posted November 11, 2018 Share Posted November 11, 2018 Just to clarify: You've built your own login event handler that is ran onStart This event is set to asynchronous with a timeout of 5000ms If you fail to login, the script should stop If you successfully login, the script should proceed to the onLoop The onLoop firstly checks to make sure you're logged in If I've got this correct, then I don't think this is the right approach, because the onLoop will be called once onStart has been executed. You could block the onStart to delay the loop, but I would advise against it because onStart is only called once, and if there's a problem in its execution, the entire script would have to be restarted. Instead, I would handle all this within the loop; you can use a combination of boolean checks and timestamps to see where you are and where you should be: onLoop IF logged in DO stuff ELSE IF we have entered in our login details IF we have clicked the login button IF 5 seconds have passed DO stop script ELSE DO click login ELSE enter in login information 1 Quote Link to comment Share on other sites More sharing options...
jca Posted November 11, 2018 Author Share Posted November 11, 2018 1 hour ago, liverare said: Just to clarify: You've built your own login event handler that is ran onStart This event is set to asynchronous with a timeout of 5000ms If you fail to login, the script should stop If you successfully login, the script should proceed to the onLoop The onLoop firstly checks to make sure you're logged in If I've got this correct, then I don't think this is the right approach, because the onLoop will be called once onStart has been executed. You could block the onStart to delay the loop, but I would advise against it because onStart is only called once, and if there's a problem in its execution, the entire script would have to be restarted. Instead, I would handle all this within the loop; you can use a combination of boolean checks and timestamps to see where you are and where you should be: onLoop IF logged in DO stuff ELSE IF we have entered in our login details IF we have clicked the login button IF 5 seconds have passed DO stop script ELSE DO click login ELSE enter in login information Thanks for the reply... yeah the event is non blocking. The tricky part is I swap login details so the login event also listens to that. I actually switched to your approach to test it and it is flawless now. Good to have confirmation of my thinking though! Quote Link to comment Share on other sites More sharing options...