sometimes icemaker

For quite some time now the icemaker has been making ice on a very irregular schedule. If I buy ice and open the bin and dump it in, the icemaker will make about one tray’s worth, then stop. I have removed the icemaker and checked the timer, etc. If I remove the unit and reinstall it, it will occaisionally make a few trays worth, then quit.
What is the black gizmo on the red wire in the wiring harness? It just looks like a black hard plastic thing. Resistor or something? Could it be the issue? Do I need a new icemaker?
I am relatively disappointed with the unit as a whole, but don’t want to try and justify a new refrigerator to the Admiral over an icemaker.
Thanks for your help.
Doug:)