afterLogin handler crashing randomly

Hello,

App Id: 8149FCCE-07DA-F988-FFBB-6154872C9500

First, I’m trying to add an afterLogin handler in debug mode using Code Runner. With some regularity, I get the following error when calling npm run debug:

13:37:53.701 Services (1):
13:37:53.701   FileSupport (services/fileSupport.js)
13:37:53.702 Connection to Redis...
13:37:53.913 Registering Code Runner on https://api.backendless.com
13:37:54.363 Unable to register Runner. Runner registration failed. Please copy Code Runner ID from console, press Attach and run CodeRunner with Code Runner ID

I am currently unable to add the handler at all - I’ve tried everything I can think of to clear the error, but I’m now dead in the water.

Second, when I could add the handler, calls to UserService.login crash it most of the time (sometimes it works) with the following:

Backendless encountered an error while handling the request. An internal trouble ticket with ID 547D45A2-685B-4D45-FF8B-50B7359BF800 has been created and we will be investigating the issue.
null
java.lang.NullPointerException
	at com.backendless.servercode.CodeRunnerDebugStatus.getConnectionStatusFromRedis(CodeRunnerDebugStatus.java:69)
	at com.backendless.servercode.codeBinding.EventHandlerInvoker.execute(EventHandlerInvoker.java:64)
	at com.backendless.servercode.codeModel.ModelCodeExtender.lambda$executeBinding$0(ModelCodeExtender.java:224)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at com.backendless.servercode.codeModel.ModelCodeExtender.executeBinding(ModelCodeExtender.java:223)
	at com.backendless.servercode.codeModel.ModelCodeExtender.executeAfter(ModelCodeExtender.java:202)
	at com.backendless.servercode.codeModel.ModelCodeExtender.performActionWithValidationUnsafe(ModelCodeExtender.java:164)
	at com.backendless.servercode.codeModel.ModelCodeExtender.performActionWithValidation(ModelCodeExtender.java:105)
	at com.backendless.servercode.codeModel.ModelCodeExtender.performActionWithValidation(ModelCodeExtender.java:92)
	at com.backendless.services.users.impl.CustomLogicDecorator.performActionWithValidation(CustomLogicDecorator.java:95)
	at com.backendless.services.users.impl.CustomLogicDecorator.login(CustomLogicDecorator.java:103)
	at com.backendless.services.users.impl.UserServiceClientsProxyOrigin.login(UserServiceClientsProxyOrigin.java:282)
	at com.backendless.inject.interceptors.GoogleAnalyticInterceptor.invoke(GoogleAnalyticInterceptor.java:29)
	at com.backendless.inject.interceptors.AbstractApiCallInterceptor.lambda$invoke$0(AbstractApiCallInterceptor.java:51)
	at com.backendless.services.RunnerService.executeApiCall(RunnerService.java:63)
	at com.backendless.inject.interceptors.AbstractApiCallInterceptor.invoke(AbstractApiCallInterceptor.java:48)
	at com.backendless.gamification.AbstractGamificationInterceptor.invoke(AbstractGamificationInterceptor.java:66)
	at controllers.Users.lambda$login$11(Users.java:316)
	at com.backendless.async.BackendlessExecutorService.lambda$submit$0(BackendlessExecutorService.java:106)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

It isn’t caused by my code, it does the same thing when I install the downloaded “scaffold” handler generated in the console. Also, when it crashes, it isn’t being called, as is obvious from the Code Runner output.

Thanks

I’ve tried waiting this out to see if old code gets cleaned up, but I simply can no longer use Code Runner. And I’m dead in the water. I can’t add any handlers now. I’m using a simple, nearly empty model, and I switched to a simple beforeLogin handler instead of the afterLogin handler I reported above. Nothing I do changes the error. I have no idea what the advice in Code Runner “Please copy Code Runner ID from console, press Attach and run CodeRunner with Code Runner ID” means. There is nothing helpful in my log files.

I don’t think this is anything I’m doing - any advice please? I am hesitant to try too many things that have to do with the login process - I don’t want to interfere with the app’s users so I’m pretty much stuck until I understand the nature of this error.

Thank you

Hello @Kelly_Oglesby,

did you run npm install after you’ve downloaded your business logic?
Have you tried to update the backendless-coderunner version in the package.json to the latest (v6.4.4 currently)?

Regards,
Stanislaw

I will definitely upgrade code-runner, but all of my problems are on the server. I tried adding a beforeLogin handler using the console, and just editing the code right in that interface to remove code-runner from the loop. When saving and deploying it, lots of problems showed up. The afterLogin handler that was the subject of my original report showed up in the list both as production and debug, which is weird since I never deployed it, and since code-runner wasn’t running - so it was an artifact - but that explains the “Unable to register runner” error. I tried to delete it but it kept coming back. It showed up twice in the list, as did the market-* login handlers that are always there. However, all of my File context handlers also disappeared. The handler defined in the console still threw the exception described above whenever I called login() from the client. It was a real mess. Out of panic, I removed all of the handlers from my project temporarily and re-deployed. That seemed to clean up whatever hosed state was on the server. I added them back and deployed again, and right now everything seems to be back where I started. For now, I’m going to go a different direction and handle this particular problem on the client side. Thank you!