Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction documentation shows wrong usage #10008

Closed
p-mongo opened this issue Mar 10, 2021 · 0 comments
Closed

Transaction documentation shows wrong usage #10008

p-mongo opened this issue Mar 10, 2021 · 0 comments
Assignees
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@p-mongo
Copy link

p-mongo commented Mar 10, 2021

Do you want to request a feature or report a bug?

Report a bug.

What is the current behavior?

The documentation at https://mongoosejs.com/docs/transactions.html suggests wrong usage of transactions.

The first example shown uses a single commitTransaction call being used.
This pattern would fail transactions when there are transient errors, such as network errors or write conflicts.

The correct usage is shown in https://docs.mongodb.com/manual/core/transactions/ (click on node.js for node examples) and involves using the withTransaction driver helper to retry operations automatically upon transient errors.

The correct pattern is shown halfway down the page but should be the default pattern used by most applications and should thus be the first example shown.

Users are mistakenly applying the first shown pattern incorrectly. See, for example, https://stackoverflow.com/questions/63541192/how-can-i-test-mongoose-session-transactions-error-mongooseerror-connection-1#comment117662935_63541192.

What is the expected behavior?

The first, and most prominent, example should utilize the withTransaction helper.

The documentation should explicitly state that manually calling commitTransaction as in the first currrently shown example is generally incorrect and should only be used in very few cases when manual transaction control is desired.

See, e.g., for reference: https://docs.mongodb.com/ruby-driver/master/tutorials/ruby-driver-transactions/

@IslandRhythms IslandRhythms added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Mar 16, 2021
@vkarpov15 vkarpov15 added this to the 5.12.2 milestone Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

3 participants