You're missing the 'type' option for the endArrow and also the 'size'
should not be inside the 'attrs' object but outside it instead.
This is the correct format for your case:
endArrow: { type: 'basic', size: size, attrs: { fill:color, stroke:
color } }
Cheers,
David