Skip to content

_result_types grows unbounded for unanswered requests #608

@meymchen

Description

@meymchen

Component

pygls/protocol/json_rpc.py

Summary

For every outgoing request, _result_types[msg_id] is populated but only removed when a response is received. If the remote peer never responds (due to timeout, crash, or network loss), the entry leaks indefinitely.

Steps to Reproduce

  1. Send a request to a peer that will never answer.
  2. _result_types retains the mapping forever.

Expected Behavior

Entries should be cleaned up when the corresponding future is cancelled or garbage-collected.

Actual Behavior

Memory leak for every unanswered request.

Affected Code (pygls/protocol/json_rpc.py, ~L697-698)

self._request_futures[msg_id] = future
self._result_types[msg_id] = self.get_result_type(method)

Proposed Fix

Add a done-callback to future that pops the _result_types entry even when no response arrives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions