Cursor.Close accepts context which could result in cancelling the close operation

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.3.5
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      mongodb-go-driver accepts a context for the Cursor.CloseSession.EndSession, transaction, etc. This looks like a problem to me, as context is used for cancellation and cancelling a close operation is not really desired (Leaking the cursor).

      I can try just passing context.Background() specifically to such close methods, but that seems very error prone.

      You would often use context by taking the HTTP request context, which gets cancelled if the connection is severed for any reason, and possibly add a Mongo session on top of it if desired (UseSession). If I then just pass context.Background(), it won't use the session for those close operations which I'm not sure is correct or even going to work.

            Assignee:
            Divjot Arora (Inactive)
            Reporter:
            Shay Katz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: