[GODRIVER-2769] Use the Context passed to "FindOne" in the "SingleResult" as well Created: 11/Mar/23  Updated: 28/Oct/23  Resolved: 21/Mar/23

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.12.0

Type: New Feature Priority: Unknown
Reporter: Matt Dale Assignee: Preston Vasquez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed
Documentation Changes Summary:

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?


 Description   

Currently calling FindOne returns a SingleResult that uses a context.TODO (the same behavior as a context.Background) to fetch results from the underlying cursor (if they weren't returned with the initial batch). That could create a scenario where iterating the underlying cursor hangs indefinitely, violating the user's expectation that the Context passed to FindOne should limit all blocking calls related to the FindOne operation.

Definition of done:

  • Pass the Context used in FindOne (and all other functions that return a SingleResult) to the SingleResult and use it when fetching the document from the cursor if it hasn't already been returned.
    • Specifically, replace the uses of context.TODO here and here with the Context from the FindOne (or other) function call.


 Comments   
Comment by Githook User [ 21/Mar/23 ]

Author:

{'name': 'Preston Vasquez', 'email': 'prestonvasquez@icloud.com', 'username': 'prestonvasquez'}

Message: GODRIVER-2769 add context to SingleResult (#1205)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/e1c93b560dbdc8a6344a9287c43fc99b4a5d9cbd

Generated at Thu Feb 08 08:39:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.