Backend Function Only Works Once

I have a backend function that removes some things from a database and delete some things from an s3 bucket. This function works fine the first time but when called again it returns this error:

FunctionNotFoundError: Error loading function from web module backend/fModule.jsw: function ‘DeleteOne’ not found

If I refresh the page it throws up the same error the first time. It will only work again if I re-publish the page so I am assuming that it must be something in the backend causing it as it is not effected by the refresh?

Does anyone have any ideas?