STM32 CAN bus receive interrupt is sometimes not fired, and CAN transmit sometimes times out
I chatted with an STM32 employee about this problem some time ago, and he wrote I had to wait until the next version of the HAL library. My version at that time was version 1.6.
In version 1.7 of the HAL library the problem is solved.

I moved to another communication method so never tried CAN with the new version 1.7, but this should solve the CAN transmit error, specifically on STM32F103. I have been notified by tyr.bentsen (see answer/comment of him in this post). Thanks for the notification.

The software can be downloaded from ST.com:

stm32cubef1

Scroll to the bottom where you see the software installations and download the STM32CubeF1 1.7 and Patch_CubeF1 1.7.1.