# Buggy code
async def remote(self, request_data: Optional[Union[Dict, Any]] = None, **kwargs):
    """Issue an asynchrounous request to the endpoint.

    Returns a Ray ObjectRef whose results can be waited for or retrieved
    using ray.wait or ray.get (or ``await object_ref``), respectively.

    Returns:
        ray.ObjectRef
    Args:
        request_data(dict, Any): If it's a dictionary, the data will be
            available in ``request.json()`` or ``request.form()``.
            Otherwise, it will be available in ``request.body()``.
        ``**kwargs``: All keyword arguments will be available in
            ``request.query_params``.
    """
    return await self.router._remote(
        self.endpoint_name, self.handle_options, request_data, kwargs
    )


# Traceback (TypeError)
2021-01-04 21:15:59,360	INFO services.py:1173 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=6369) 2021-01-04 21:16:01,432	INFO controller.py:346 -- Starting router with name 'hRhwaS:SERVE_CONTROLLER_ACTOR:SERVE_PROXY_ACTOR-node:192.168.31.141-0' on node 'node:192.168.31.141-0' listening on '127.0.0.1:8000'
(pid=6366) INFO:     Started server process [6366]
Traceback (most recent call last):
File "a.py", line 11, in <module>
ray.put(handle)
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/worker.py", line 1411, in put
object_ref = worker.put_object(value, pin_object=True)
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/worker.py", line 262, in put_object
serialized_value = self.get_serialization_context().serialize(value)
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 406, in serialize
return self._serialize_to_msgpack(value)
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 386, in _serialize_to_msgpack
self._serialize_to_pickle5(metadata, python_objects)
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 346, in _serialize_to_pickle5
raise e
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 343, in _serialize_to_pickle5
value, protocol=5, buffer_callback=writer.buffer_callback)
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 73, in dumps
cp.dump(obj)
File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 563, in dump
return Pickler.dump(self, obj)
File "stringsource", line 2, in ray._raylet.Count.__reduce_cython__
TypeError: self.c_tag_keys,self.metric cannot be converted to a Python object for pickling
(pid=6369) 2021-01-04 21:16:03,924	INFO controller.py:753 -- Registering route 'f' to endpoint 'f' with methods '['GET']'.
2021-01-04 21:16:06,021	INFO api.py:65 -- Shutting down Ray Serve because client went out of scope. To prevent this, either keep a reference to the client object or use serve.start(detached=True).

# Fixed code
async def remote(self, request_data: Optional[Union[Dict, Any]] = None, **kwargs):
    """Issue an asynchronous request to the endpoint.

    Returns a Ray ObjectRef whose results can be waited for or retrieved
    using ray.wait or ray.get (or ``await object_ref``), respectively.

    Returns:
        ray.ObjectRef
    Args:
        request_data(dict, Any): If it's a dictionary, the data will be
            available in ``request.json()`` or ``request.form()``.
            Otherwise, it will be available in ``request.body()``.
        ``**kwargs``: All keyword arguments will be available in
            ``request.query_params``.
    """
    return await self.router._remote(
        self.endpoint_name, self.handle_options, request_data, kwargs
    )