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

[C# Client] Stacktraces and log lines are broken #42

Open
TheDutchDev opened this issue Dec 22, 2024 · 1 comment
Open

[C# Client] Stacktraces and log lines are broken #42

TheDutchDev opened this issue Dec 22, 2024 · 1 comment

Comments

@TheDutchDev
Copy link

When an exception occurs on the client-side, the stacktrace is often all over the place and therefore mostly useless.

For example:

[16:35:26][Error][C#] Exception in timer at lacnr-cs-client G:\ALTV DEV\server-resources\cnr-cs-server\CopsAndRobbers.Client\Features\Peds\Base\WeaponizedPed.cs:32: AltV.Net.Elements.Entities.EntityRemovedException: Entity(Type=Ped, id=246) got removed.

   at AltV.Net.Client.Elements.Entities.Entity.CheckIfEntityExists()

   at AltV.Net.Client.Elements.Entities.Entity.GetStreamSyncedMetaData[T](String key, T& result)

   at CopsAndRobbers.Client.Features.Peds.Base.DynamicPed.get_TargetEntityType()

   at CopsAndRobbers.Client.Features.Peds.Base.DynamicPed.GetTargetScriptId() in G:\ALTV DEV\server-resources\cnr-cs-server\CopsAndRobbers.Client\Modules\Minigames\CircuitBreaker\CbGenericPorts.cs:line 193

   at CopsAndRobbers.Client.Features.Peds.Base.WeaponizedPed.AttackTarget()

   at CopsAndRobbers.Client.Features.Peds.Base.WeaponizedPed.On500Ms()

   at AltV.Net.Client.Elements.Entities.ModuleTimer.Update(Int64 curTime, String resourceName)

Now, regardless of the exception itself (I was messing around with stuff), note how it tells me it's coming from CbGenericPorts.cs:line 193. But that file has nothing to do with this entire class. It's not even being used anywhere (I never instantiate it as I don't use that file yet). So how come this thing pops up out of nowhere?

Additionally, I was working on a custom logger and wanted to use [CallerLineNumber] attribute. Which works, but again is showing up on the wrong lines (randomly).

For example:

[12:52:57][C#] [Information] [PedTrafficInterval.OnInterval:29] | vehicle count: {Count}
[12:52:57][C#] [Information] [PedTrafficInterval.OnInterval:114] | nodes: []

Now, the first one is completely wrong. It mentions that the log originates from line 29. However, line 29 is this:

    private Task RunInterval()
    { // <------ This is line 29
        return Task.Run(async () =>
        {
            while(!_cts.IsCancellationRequested)
            {

The real location of the log is actually on line 61:

        _logger.Information("vehicle count: {Count}", args: vehiclePositions.Count);

The second log (nodes: []) actually does show up on the correct line number though. So line 114 is actually where the line in the code is located as well. So it does work, but not all the time?

Imho this is a pretty breaking issue and high priority because:

  • We can't use debuggers client-side (so no breakpoints etc)
  • Without debuggers, one has to rely on exceptions, stacktraces and log lines
  • But stacktraces and log lines are also inconsistent and unreliable, so how can we properly find and debug client-side issues?
@Kaiwoknats
Copy link
Contributor

Yes this issue is just really anyoing and doesnt make it easier to fix bugs at all. We had issues laying deep beeing hidden by this faulty behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants