Skip to content

Error when calling GetOrCreateCurrentOrderAsync after upgrading from v14 to v15 #715

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

Open
jwolke opened this issue May 27, 2025 · 0 comments
Labels
bug Something isn't working component/commerce

Comments

@jwolke
Copy link

jwolke commented May 27, 2025

Which component is this issue related to?

Umbraco Commerce (Core)

Which Umbraco Commerce version are you using? (Please write the exact version, example: 10.1.0)

15.3.4

Bug summary

I recently upgraded from v14.1.5 to v15.4.1 of Umbraco Commerce and I am running into an issue in the CartSurfaceController code that I copied from the Demo Store. I am encountering the following error on this line of code:

var order = await _commerceApi.GetOrCreateCurrentOrderAsync(store.Id) .AsWritableAsync(uow);

Error:

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Umbraco.Commerce.Web
StackTrace:
at Umbraco.Commerce.Web.Session.CookieSessionStore.GetValue[T](String key)
at Umbraco.Commerce.Core.Session.SessionManager.<>c__DisplayClass43_0.<b__0>d.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.d__1011.MoveNext() at Umbraco.Commerce.Core.Session.SessionManager.<>c__DisplayClass56_0.<<GetDefaultShippingMethodAsync>b__0>d.MoveNext() at Umbraco.Commerce.Core.Session.SessionManager.<WithSessionStoreAsync>d__1011.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.<>c__DisplayClass14_0.<b__1>d.MoveNext()
at Umbraco.Commerce.Core.UmbracoCommerceUnitOfWorkProvider.d__221.MoveNext() at Umbraco.Commerce.Core.UmbracoCommerceUnitOfWorkProvider.<ExecuteWithUnitOfWorkAsync>d__221.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.d__14.MoveNext()
at Umbraco.Commerce.Core.Session.SessionManager.d__13.MoveNext()
at Umbraco.Commerce.Extensions.AggregateBaseExtensions.d__7.MoveNext()
at GeneTools.Core.Web.Controllers.CartSurfaceController.<>c__DisplayClass2_0.<b__0>d.MoveNext() in C:\dev\genetools\src\GeneTools.Core\Web\Controllers\CartSurfaceController.cs:line 36

This exception was originally thrown at this call stack:
[External Code]
GeneTools.Core.Web.Controllers.CartSurfaceController.AddToCart.AnonymousMethod__0(Umbraco.Commerce.Common.IUnitOfWork) in CartSurfaceController.cs

We are using the same code as the demo store. Based on my debugging, the error seems to happen in the GetCurrentAdminOrderAsync() method of the Umbraco.Commerce.Core.Session::SessionManager.cs class

When I switch to using the Result rather than awaiting the call to GetOrCreateCurrentOrderAsync, everything works as expected:

var order = _commerceApi.GetOrCreateCurrentOrderAsync(store.Id).AsWritableAsync(uow).Result;

Specifics

No response

Steps to reproduce

TBD

Expected result / actual result

No response

Dependencies

No response

@jwolke jwolke added the bug Something isn't working label May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component/commerce
Projects
None yet
Development

No branches or pull requests

1 participant