Add some debug messages for random test failures. (#18216)
This commit is contained in:
@@ -63,7 +63,12 @@ public sealed class UserDbDataManager
|
||||
|
||||
public bool IsLoadComplete(IPlayerSession session)
|
||||
{
|
||||
return _users[session.UserId].Task.IsCompleted;
|
||||
return GetLoadTask(session).IsCompleted;
|
||||
}
|
||||
|
||||
public Task GetLoadTask(IPlayerSession session)
|
||||
{
|
||||
return _users[session.UserId].Task;
|
||||
}
|
||||
|
||||
private sealed record UserData(CancellationTokenSource Cancel, Task Task);
|
||||
|
||||
@@ -120,9 +120,28 @@ namespace Content.Server.GameTicking
|
||||
|
||||
async void SpawnWaitDb()
|
||||
{
|
||||
// Temporary debugging code to fix a random test failures
|
||||
var initialStatus = _userDb.GetLoadTask(session).Status;
|
||||
var prefsLoaded = _prefsManager.HavePreferencesLoaded(session);
|
||||
DebugTools.Assert(session.Status == SessionStatus.InGame);
|
||||
|
||||
await _userDb.WaitLoadComplete(session);
|
||||
|
||||
try
|
||||
{
|
||||
SpawnPlayer(session, EntityUid.Invalid);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"Caught exception while trying to spawn a player.\n" +
|
||||
$"Initial DB task status: {initialStatus}\n" +
|
||||
$"Prefs initially loaded: {prefsLoaded}\n" +
|
||||
$"DB task status: {_userDb.GetLoadTask(session).Status}\n" +
|
||||
$"Prefs loaded: {_prefsManager.HavePreferencesLoaded(session)}\n" +
|
||||
$"Exception: \n{e}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
async void SpawnObserverWaitDb()
|
||||
{
|
||||
|
||||
@@ -17,5 +17,6 @@ namespace Content.Server.Preferences.Managers
|
||||
bool TryGetCachedPreferences(NetUserId userId, [NotNullWhen(true)] out PlayerPreferences? playerPreferences);
|
||||
PlayerPreferences GetPreferences(NetUserId userId);
|
||||
IEnumerable<KeyValuePair<NetUserId, ICharacterProfile>> GetSelectedProfilesForPlayers(List<NetUserId> userIds);
|
||||
bool HavePreferencesLoaded(IPlayerSession session);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user