Skip to content

Deduplicate concurrent DocumentConnectionManager.connect() calls for the same virtual document URI #1192

Description

@MUFFANUJ

Elevator Pitch

In environments with rapid editor events and custom transports, multiple concurrent connect() calls can race for the same virtualDocument.uri.

In jupyterlab/plugin-playground PR #225, we patch ILSPDocumentConnectionManager.connect() at runtime and maintain a pendingConnects map keyed by URI to dedupe in-flight connects.

This behavior should be in core to avoid monkeypatches and duplicated downstream fixes.

Design Ideas

Implement built-in in-flight dedupe in DocumentConnectionManager.connect():

  • Before creating a connection, check:
    • existing settled connection for URI
    • existing pending connect promise for URI
  • Reuse pending promise when available.
  • Clear pending state on settle (success/failure).

An alternative is exposing an official policy hook for connect coalescing, but built-in dedupe seems broadly useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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