Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5233

Throw if a session is used that came from another mongo client

    • 3
    • Not Needed
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      As a Node driver engineer,
      I want to prevent users from providing sessions from one mongo client to another,
      So that we can prevent undefined behavior for our users.

      User Impact

      • Breaking Change Users passing sessions started on other clients will now have errors thrown from operations

      Dependencies

      • None

      Unknowns

      • should we throw an error if the user provides a session from one client to another? or should we silently create an implicit session?
        • errors will make it incompatible with existing code but that's why we are putting this out in a major version
      • best way to identify client? - instanceof is brittle, we can generate a unique id and/or use a symbol property; needs to account for legacy client usage
        • what other identifier is there?
        • what problems are there with checking referential equality?

      Acceptance Criteria

      Implementation Requirements

      • when an explicit session is provided to a driver helper, do not attach the session to the operation if it originates from a different mongo client instance
      • Check client reference on session against reference passed to executeOperation

      Testing Requirements

      • Implement prose test 5 from the sessions spec
      • Consider additional unit tests for specific error scenarios if prose test is unable to include the correct coverage (message/error type)

      Documentation Requirements

      • Update startSession API documentation to mention this requirement

      Follow Up Requirements

      • None

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: