microservices-demo / front-end

Front-end application for ALL the microservices
Apache License 2.0
79 stars 2.25k forks source link

Sock-shop front end - Detected task failure when scaling in Docker Swarm. #108

Open wellisonraul opened 5 years ago

wellisonraul commented 5 years ago

Hello all, this is my first post and I'm afraid maybe this is not the right way to post my problem so apologies if I did it on the wrong way.

I'm using a sock shop as a test bed for my scientific research. The cluster is made of 1 master and 2 workers in the Docker Swam Mode. I am monitoring the application to make changes in your behavior. If this happens, I scale the application. For clarity, I realized that when the numbers of microservices change: "occurs detected task failure in the Docker Swarm".

So, I took the front end log and you can see it here:

sockshop_front-end.4.vn6ci38c3pqk@node-09    | /usr/src/app/api/orders/index.js:67
sockshop_front-end.4.vn6ci38c3pqk@node-09    |             var customerlink = jsonBody._links.customer.href;
sockshop_front-end.4.vn6ci38c3pqk@node-09    |                                                ^
sockshop_front-end.4.vn6ci38c3pqk@node-09    | 
sockshop_front-end.4.vn6ci38c3pqk@node-09    | TypeError: Cannot read property 'customer' of undefined
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at Request._callback (/usr/src/app/api/orders/index.js:67:48)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at Request.self.callback (/usr/src/app/node_modules/request/request.js:186:22)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at Request.emit (events.js:198:13)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1081:10)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at Request.emit (events.js:198:13)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:1001:12)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at Object.onceWrapper (events.js:286:20)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at IncomingMessage.emit (events.js:203:15)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at endReadableNT (_stream_readable.js:1145:12)
sockshop_front-end.4.vn6ci38c3pqk@node-09    |     at process._tickCallback (internal/process/next_tick.js:63:19)
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! code ELIFECYCLE
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! errno 1
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! microservices-demo-front-end@0.0.1 start: `node server.js`
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! Exit status 1
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! 
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! Failed at the microservices-demo-front-end@0.0.1 start script.
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
sockshop_front-end.4.vn6ci38c3pqk@node-09    | 
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR! A complete log of this run can be found in:
sockshop_front-end.4.vn6ci38c3pqk@node-09    | npm ERR!     /home/myuser/.npm/_logs/2019-09-03T11_57_54_133Z-debug.log

This usually occurs after the scale increases or decreases. The time between the problem and the normal sockshop is 10 minutes. However, during this time the application becomes unavailable for use. All front end microservices often fail when this problem occurs.

I don't know if the information is sufficient to understand the issue, but I can investigate and submit more.

Any help is highly appreciated. Thanks all. Wellison Santos.

rajibhossen commented 3 years ago

You are probably trying to add to the cart without logging in first. as a result, the cart database kept userid as "undefined" and when the system tries to read, it gets an error because there's no customer object on "undefined" userid. Please ensure to log in first before adding an item to the cart.