Search code examples
javasap-commerce-cloudadd-on

SAP Hybris Assisted Service Module (ASM) - double login


I've got a problem with ASM module - sometimes it happens that after Login action, the site is refreshed and ASM not shown.
I found that when I'm logging in, the request is sent twice at the same time. Then it leads to error with duplicated keys found in DB. I think the main problem is the double login, but I don't know what causes it.

[RQ-XXX/user-POST /custom/cs/assisted-service/login] [ip] [AssistedServiceFacade] Agent [user] has been loged in using login form
[RQ-XXX/user-POST /custom/cs/assisted-service/login] [ip] [DefaultGUIDCookieStrategy] Setting guid cookie and session attribute: xxx
[RQ-XXX/user-POST /custom/cs/assisted-service/login] [ip] [AssistedServiceFacade] Agent [user] has been loged in using login form
[RQ-XXX/user-POST /custom/cs/assisted-service/login] [ip] [DefaultGUIDCookieStrategy] Setting guid cookie and session attribute: yyy
ERROR [RQ-end] [page] Error 200 shown
 Req: null
 User:user
 Session:xxx | msg:
java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
    at sun.nio.ch.IOUtil.write(IOUtil.java:65)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:468)
.
.

This is the key error, but I'm not really sure it's the main cause of the problem.

ModelSavingException: [de.hybris.platform.servicelayer.interceptor.impl.UniqueAttributesInterceptor@2f9e23c2]:Ambiguous unique keys {key=CxActionResults_XXX} for model CxResultsModel (<unsaved>) –  found 1 item(s) using the same keys

I tried to prevent that with a .js but it didn't help:

$("#asmLoginForm").on('submit', function (e) {
   e.preventDefault();
})

It doesn't happen every time.


Solution

  • Turns out there was bad wro configuration. I had the .js files from ASM module twice on the site, once compiled in all_responsive.js file and once again in the addons/responsive part. So everytime I did submit, both two functions sent the request.