Server side CreateVehicle sometimes spawns non-networked vehicles for clients

Incident

Summary:
Several of my customers keep running into an issue that was really difficult for me to find the culprit. One of my scripts (Advancedparking) uses the native CreateVehicle on server side to spawn its vehicles. But sometimes only a certain client was able to see that vehicle. Turns out that this native can sometimes cause a non-networked vehicle to spawn.

Expected behavior:
Server side CreateVehicle creates networked vehicles that can be seen for all clients.

Actual behavior:
Using the server side CreateVehicle native can sometimes lead to non-networked vehicles being spawned for a client. Obviously this vehicle only exists for that client then.

Steps to reproduce:
The following function is what I use to spawn vehicles (but cut down a little to its essential parts):

Server side spawn function
local SPAWN_TIMEOUT = 30000
-- spawn a vehicle from its data
function SpawnVehicle(id, vehicleData)
	if (vehicleData.model == nil) then
		return
	end

	local vehicle = CreateVehicle(vehicleData.model, vehicleData.position, vehicleData.rotation.z, true, true)

	local timer = GetGameTimer()
	while (not DoesEntityExist(vehicle)) do
		Citizen.Wait(0)

		if (timer + SPAWN_TIMEOUT < GetGameTimer()) then
			-- timeout
			LogWarning("Hit timeout while spawning vehicle \"%s\".", id)

			return
		end
	end

	SetEntityCoords(vehicle, vehicleData.position)
	SetEntityRotation(vehicle, vehicleData.rotation)

	vehicleData.handle = vehicle

	LogDebug("Creating vehicle \"%s\" at %s", id, vehicleData.position)
end
Client side command
RegisterCommand("bug", function(src, args, raw)
    local vehicle = GetClosestVehicle(GetEntityCoords(PlayerPedId()), 0.5)
    if (vehicle) then
        print("Plate", GetVehicleNumberPlateText(vehicle))
        print("Network", NetworkGetEntityIsNetworked(vehicle))
    end
end, false)

function GetClosestVehicle(position, maxRadius)
	local dist = maxRadius
	local closestVehicle = nil

	for i, vehicle in ipairs(GetGamePool("CVehicle")) do
		local tempDist = #(GetEntityCoords(vehicle) - position)
		if (tempDist < dist) then
			dist = tempDist
			closestVehicle = vehicle
		end
	end

	return closestVehicle
end

Any additional info:
This keeps happening for a lot of different servers so I cannot really pinpoint it to specific versions. But it definitely happens for Windows and Linux users. Most of them are now running the latest recommended and Onesync Infinity (after I told them to use that one) but it used to happen on older and newer server versions.
Some of them don’t have problems at all, for some others it happens really often (like 1 in 5 vehicles).
Some of them only have the issue with a lot of online players, others can be alone in a server and still get those non-networked vehicles to spawn.
Most of them are using a combination of different onesync convars although they do not seem to make a difference to the problem:

set onesync_workaround763185 true
set onesync_forceMigration true
set onesync_distanceCullVehicles true
set onesync_population false

I am currently using a workaround to at least keep the script running for those people for now:
After hitting the “spawn timeout” I trigger a client event that checks if there is a non-networked vehicle at the original position and delete it. And after that I basically run the SpawnFunction again.