From 788c535063719eb521a9c7574b483bf6a70d22ed Mon Sep 17 00:00:00 2001 From: evanlihou Date: Sat, 18 Jan 2025 19:23:20 -0500 Subject: [PATCH] Update packages to stable and fix bug that occurs after a container receives 20 requests --- FiMAdminApi.Data/FiMAdminApi.Data.csproj | 6 +++--- FiMAdminApi/FiMAdminApi.csproj | 4 ++-- FiMAdminApi/Program.cs | 9 ++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/FiMAdminApi.Data/FiMAdminApi.Data.csproj b/FiMAdminApi.Data/FiMAdminApi.Data.csproj index 24494db..f38056d 100644 --- a/FiMAdminApi.Data/FiMAdminApi.Data.csproj +++ b/FiMAdminApi.Data/FiMAdminApi.Data.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/FiMAdminApi/FiMAdminApi.csproj b/FiMAdminApi/FiMAdminApi.csproj index ee87780..fabae3a 100644 --- a/FiMAdminApi/FiMAdminApi.csproj +++ b/FiMAdminApi/FiMAdminApi.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/FiMAdminApi/Program.cs b/FiMAdminApi/Program.cs index d48a20c..09e492f 100644 --- a/FiMAdminApi/Program.cs +++ b/FiMAdminApi/Program.cs @@ -58,11 +58,18 @@ throw new ApplicationException("FiM Connection String is required"); } +// IMPORTANT! +// This null name translator should be a singleton, and should *not* be +// refactored back inside the `AddDbContext`. Having a new one constructed +// every time confuses EF's ServiceProviderCache, meaning it has to use a new +// service provider for every request. +var nullNameTranslator = new NpgsqlNullNameTranslator(); + builder.Services.AddDbContext(opt => { opt.UseSnakeCaseNamingConvention(); opt.UseNpgsql(connectionString, - o => o.MapEnum("tournament_level", nameTranslator: new NpgsqlNullNameTranslator())); + o => o.MapEnum("tournament_level", nameTranslator: nullNameTranslator)); }); // For most authn/authz we're using tokens directly from Supabase. These tokens get validated by the supabase auth