vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.6k stars 991 forks source link

throw new QueryRunnerAlreadyReleasedError() #2868

Open onursonmez opened 3 months ago

onursonmez commented 3 months ago

I developed the Wishlist plugin located at https://docs.vendure.io/guides/developer-guide/plugins/. When I successively click on the Login, AddtoWishlist, GetWishlist, RemoveFromWishlist mutations from the http://localhost:3000/shop-api screen, Vendure Server crashes and I get the error in the screenshot below.

To Reproduce Steps to reproduce the behavior: Enter the http://localhost:3000/shop-api screen and prepare 4 mutations that log in, insert, get and remove. Run these mutations one after another by pressing the play button. Vendure Server will crash.

Expected behavior Vendure Server should not crash due to Postgresql in consecutive queries.

Environment (please complete the following information):

onursonmez commented 3 months ago
@Mutation()
@Transaction()

It was fixed when I changed the above code in the wishlist.resolver.ts file as follows, that is, deleted the @Transaction() part.

@Mutation()

Do you have any idea why he's doing this? Is @Transaction expecting multiple triggers? If so, the @Transaction sections in the documentation at https://docs.vendure.io/guides/developer-guide/plugins/ also need to be removed.

michaelbromley commented 3 months ago

Hi,

The solution should not be to remove the @Transaction() decorator, since we do generally want mutations to run inside transactions. I'm not sure how it is that running the mutations one after the other causes the issue you reported. I'll see if I can reproduce.

michaelbromley commented 3 months ago

I am not able to reproduce this (see screen recording).

https://github.com/vendure-ecommerce/vendure/assets/6275952/a72cf50a-2a98-4ff0-a409-acb9fe7f6250