NuggoDEV / NuggoDEV/CountersPlus

Exception thrown during custom counter creation will break other counters

Open
#102 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
152
Forks
35
PR merge metrics
No merged PRs in 30d

Description

Describe the Bug
As the title, when Counter+ broadcasts a level start event to all the custom counters, if there is an uncought exception, it will cause this broadcast function to terminate. As a result all the counters that would load after this bugged counter will not reveive the event. Then they won't load.

Attach or Link Files
This comment in the issue of my custom counter shows the log when my custom counter threw an uncought exception.

[INFO @ 19:46:02 | HRCounter] Refreshing Settings
[INFO @ 19:46:02 | HRCounter] Creating counter
[INFO @ 19:46:02 | HRCounter] Creating new WebSocket
[INFO @ 19:46:02 | _] 14/08/2021 19:46:02|Fatal|WebSocket.connect|An error has occurred during a TLS handshake.
[CRITICAL @ 19:46:02 | SiraUtil] Error occurred while initializing IInitializable with type 'CountersPlus.Counters.Event_Broadcasters.CounterEventBroadcaster'
[CRITICAL @ 19:46:02 | SiraUtil] System.InvalidOperationException: The current state of the connection is not Open.
[CRITICAL @ 19:46:02 | SiraUtil]   at WebSocketSharp.WebSocket.Send (System.String data) [0x0001a] in <7a2bdf4fe6004810ba771c682597b1d8>:0 
[CRITICAL @ 19:46:02 | SiraUtil]   at HRCounter.Data.HypeRate.CreateAndConnectSocket () [0x0007e] in <058d33a233044f7692f5b438d1c18b19>:0 
[CRITICAL @ 19:46:02 | SiraUtil]   at HRCounter.Data.HypeRate.Start () [0x00007] in <058d33a233044f7692f5b438d1c18b19>:0 
[CRITICAL @ 19:46:02 | SiraUtil]   at HRCounter.HRCounter.CounterInit () [0x00053] in <058d33a233044f7692f5b438d1c18b19>:0 
[CRITICAL @ 19:46:02 | SiraUtil]   at CountersPlus.Counters.Event_Broadcasters.CounterEventBroadcaster.Initialize () [0x00015] in <85e7d6fc15a141cb8afa3ea6afdf8fc6>:0 
[CRITICAL @ 19:46:02 | SiraUtil]   at (wrapper dynamic-method) Zenject.InitializableManager.DMD<Zenject.InitializableManager::Initialize>(Zenject.InitializableManager)

Maybe add a try block into the CounterEventBroadcaster.Initialize foreach loop? So a bugged counter won't affect others.

Additional context
This problem was found when fixing my own custom counter. lol

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at CounterEventBroadcaster.Initialize and inspect the foreach loop that broadcasts the level start event to custom counters. Reproduce the failure with a counter that throws during initialization, then verify that later counters still receive the event when one counter fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.