Some kind of lost connection on Samba share

Hello.
I am working on a samba server. What I do is edit some “text” files (python).
I use the Visual Studio Code. It turns out that it takes a long time to save (longer than when I connected from windows to the samba server (which by the way is a raspberry pi)). The problem would not be so much that but that every so often I lose the “connection” and I have to give it to save all the time until it recovers it …
This is not a network error, but rather seems something related to the operating system.
What could I do to improve this?
Thanks.