Team-Silver-Sphere / SquadJS

Squad Server Script Framework
Boost Software License 1.0
167 stars 128 forks source link

Discord Round Winner plugin error #391

Open pavelhoral opened 1 week ago

pavelhoral commented 1 week ago

Description of Issue

SquadJS very often crashes in discord-round-winner plugin (see bellow).

Errors or Screenshots of Issue

Squad Information

This is the SquadJS log before the crash (it happens quite often):

[2024-11-17T18:26:07.691Z][SquadServer][1] Updated layer information.
[2024-11-17T18:26:09.309Z][SquadServer][1] Updating squad list...
[2024-11-17T18:26:09.340Z][SquadServer][1] Updated squad list.
[2024-11-17T18:26:20.555Z][SquadServer][1] Fetching Admin Lists...
[2024-11-17T18:26:20.591Z][SquadServer][1] 386 admins loaded...
file:///home/container/squad-server/plugins/discord-round-winner.js:51
            value: `${info.winner} won on ${this.server.layerHistory[1].layer.name}.`
                                                                              ^

TypeError: Cannot read properties of null (reading 'name')
    at DiscordRoundWinner.onNewGame (file:///home/container/squad-server/plugins/discord-round-winner.js:51:79)
    at SquadServer.emit (node:events:531:35)
    at SquadLogParser.<anonymous> (file:///home/container/squad-server/index.js:208:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

This specific crash appeared after Manicouagan RAAS v2 - Manicouagan map ended.

System Information

pavelhoral commented 1 week ago

This is contents of the layerHistory just before a different crash:

```json [ { "layer": { "name": "Gorodok Invasion v2", "classname": "Gorodok_Invasion_v2", "layerid": "Gorodok_Invasion_v2", "map": { "name": "Gorodok" }, "gamemode": "Invasion", "version": "v2", "size": "4.0x4.0 km", "sizeType": "spline", "numberOfCapturePoints": null, "lighting": { "name": "Overcast", "classname": "LL_Gorodok_Overcast" }, "teams": [ { "faction": "Russian Airborne Forces", "name": "108th Guards Air Assault Regiment", "tickets": 200, "commander": true, "vehicles": [ { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_C", "count": 1, "spawnDelay": 6, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "BTR-DG Logistics", "classname": "BP_BTR-DG_Logistics_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "BTR-DG Logistics", "classname": "BP_BTR-DG_Logistics_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "BTR-MDM", "classname": "BP_BTRMDM_PKT_RWS_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "BTR-D Kord", "classname": "BP_BTR-D_Kord_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "BMD-1M", "classname": "BP_BMD1M_C", "count": 1, "spawnDelay": 0, "respawnDelay": 10 }, { "name": "BMD-4M", "classname": "BP_BMD4M_C", "count": 1, "spawnDelay": 0, "respawnDelay": 15 }, { "name": "BMD-4M", "classname": "BP_BMD4M_C", "count": 1, "spawnDelay": 0, "respawnDelay": 15 }, { "name": "Sprut-SDM1", "classname": "BP_Sprut_C", "count": 1, "spawnDelay": 0, "respawnDelay": 15 }, { "name": "T-72B3", "classname": "BP_T72B3_C", "count": 1, "spawnDelay": 10, "respawnDelay": 20 }, { "name": "Mi-8", "classname": "BP_MI8_VDV_C", "count": 1, "spawnDelay": 10, "respawnDelay": 6 } ], "numberOfTanks": 1, "numberOfHelicopters": 1 }, { "faction": "Irregular Militia Forces", "name": "Local Militia Brigade", "tickets": 900, "commander": true, "vehicles": [ { "name": "Armored Ural-375D Transport", "classname": "BP_Armored_Ural_375_MIL_C", "count": 1, "spawnDelay": 6, "respawnDelay": 3 }, { "name": "Armored Ural-375D Logistics", "classname": "BP_Armored_Ural_375_Logi_MIL_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "Ural-375D Logistics", "classname": "BP_Ural_375_Logi_MIL_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "Logistics Modern Pickup", "classname": "BP_Technical4Seater_Logi_Camo_C", "count": 2, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "Armored Logistics Modern Pickup", "classname": "BP_Armored_Technical4Seater_Logi_Camo_C", "count": 2, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "Modern Technical DShK", "classname": "BP_Technical2Seater_Camo_DSHK_C", "count": 2, "spawnDelay": 0, "respawnDelay": 5 }, { "name": "Armored Modern Technical M2 HB", "classname": "BP_Armored_Technical2Seater_Camo_M2_C", "count": 2, "spawnDelay": 0, "respawnDelay": 5 }, { "name": "Armored Modern Technical SPG-9", "classname": "BP_Armored_Technical2Seater_Camo_SPG9_C", "count": 2, "spawnDelay": 0, "respawnDelay": 10 }, { "name": "MT-LBM 6MB", "classname": "BP_MTLBM_6MB_MIL_C", "count": 3, "spawnDelay": 0, "respawnDelay": 10 }, { "name": "MT-LB ZU-23-2", "classname": "BP_MTLB_ZU23_MIL_C", "count": 2, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "T-62", "classname": "BP_T62_MIL_C", "count": 1, "spawnDelay": 15, "respawnDelay": 15 }, { "name": "BM-21 Grad", "classname": "BP_BM21Grad_MIL_C", "count": 1, "spawnDelay": 15, "respawnDelay": 10 } ], "numberOfTanks": 1, "numberOfHelicopters": 0 } ] }, "time": "2024-11-20T19:07:39.057Z" }, { "layer": null, "time": "2024-11-20T18:09:08.946Z" }, { "layer": { "name": "Narva RAAS v1", "classname": "Narva_RAAS_v1", "layerid": "Narva_RAAS_v1", "map": { "name": "Narva" }, "gamemode": "RAAS", "version": "v1", "size": "2.7x2.5 km", "sizeType": "spline", "numberOfCapturePoints": null, "lighting": { "name": "Partial Clouds Mid Day", "classname": "LL_Narva_MidDay_Clouds" }, "teams": [ { "faction": "United States Army", "name": "III Corps", "tickets": 300, "commander": true, "vehicles": [ { "name": "M1126 CROWS M2", "classname": "BP_M1126_Woodland_C", "count": 1, "spawnDelay": 0, "respawnDelay": 10 }, { "name": "M1126 CROWS M2", "classname": "BP_M1126_Woodland_C", "count": 1, "spawnDelay": 0, "respawnDelay": 10 }, { "name": "M2A3", "classname": "BP_BFV_Woodland_C", "count": 1, "spawnDelay": 0, "respawnDelay": 14 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Woodland_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Woodland_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M-ATV M2", "classname": "BP_MATV_Woodland_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Woodland_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M1A2", "classname": "BP_M1A2_Woodland_C", "count": 1, "spawnDelay": 15, "respawnDelay": 20 }, { "name": "M939 Transport", "classname": "BP_US_Util_Woodland_C", "count": 1, "spawnDelay": 6, "respawnDelay": 3 }, { "name": "M-ATV M2", "classname": "BP_MATV_Woodland_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 } ], "numberOfTanks": 1, "numberOfHelicopters": 0 }, { "faction": "Russian Ground Forces", "name": "49th Combined Arms Army", "tickets": 300, "commander": true, "vehicles": [ { "name": "BTR-82A", "classname": "BP_BTR82A_RUS_C", "count": 1, "spawnDelay": 0, "respawnDelay": 10 }, { "name": "BMP-2", "classname": "BP_BMP2_C", "count": 1, "spawnDelay": 0, "respawnDelay": 14 }, { "name": "BTR-82A", "classname": "BP_BTR82A_RUS_C", "count": 1, "spawnDelay": 0, "respawnDelay": 10 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "Tigr-M RWS Kord", "classname": "BP_Tigr_RWS_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "T-72B3", "classname": "BP_T72B3_C", "count": 1, "spawnDelay": 15, "respawnDelay": 20 }, { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_C", "count": 1, "spawnDelay": 6, "respawnDelay": 3 }, { "name": "BTR-80", "classname": "BP_BTR80_RUS_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 } ], "numberOfTanks": 1, "numberOfHelicopters": 0 } ] }, "time": "2024-11-20T17:13:53.046Z" }, { "layer": { "name": "Kokan AAS v1", "classname": "Kokan_AAS_v1", "layerid": "Kokan_AAS_v1", "map": { "name": "Kokan" }, "gamemode": "AAS", "version": "v1", "size": "2.5x2.5 km", "sizeType": "mapTexture", "numberOfCapturePoints": null, "lighting": { "name": "Sunny Mid Day", "classname": "LL_Kokan_Valley_MidDay_Sunny" }, "teams": [ { "faction": "United States Army", "name": "III Corps", "tickets": 250, "commander": false, "vehicles": [ { "name": "M939 Transport", "classname": "BP_US_Util_Desert_C", "count": 1, "spawnDelay": 6, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M-ATV M240", "classname": "BP_MATV_M240_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "M-ATV M240", "classname": "BP_MATV_M240_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "M-ATV M240", "classname": "BP_MATV_M240_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "M-ATV CROWS M2", "classname": "BP_MATV_CROWS_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "RHIB M240", "classname": "BP_RHIB_US_M240_C", "count": 1, "spawnDelay": 0, "respawnDelay": 1 } ], "numberOfTanks": 0, "numberOfHelicopters": 0 }, { "faction": "People's Liberation Army", "name": "2nd Heavy Combined Arms Brigade", "tickets": 250, "commander": false, "vehicles": [ { "name": "CTM131 Transport QJY88", "classname": "BP_CTM131_Desert_C", "count": 1, "spawnDelay": 6, "respawnDelay": 3 }, { "name": "CTM131 Logistics", "classname": "BP_CTM131_Logistic_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "CTM131 Logistics", "classname": "BP_CTM131_Logistic_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "CTM131 Logistics", "classname": "BP_CTM131_Logistic_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "CSK131 QJY88", "classname": "BP_CSK131_QJY88_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 5 }, { "name": "CTM131 Transport QJZ89", "classname": "BP_CTM131_QJZ89_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "CSK131 QJC88 RWS", "classname": "BP_CSK131_RWS_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 6 }, { "name": "RHIB QJY88", "classname": "BP_RHIB_QJY88_C", "count": 1, "spawnDelay": 0, "respawnDelay": 1 } ], "numberOfTanks": 0, "numberOfHelicopters": 0 } ] }, "time": "2024-11-20T16:20:52.825Z" }, { "layer": { "name": "Sumari Bala Seed v1", "classname": "Sumari_Seed_v1", "layerid": "Sumari_Seed_v1", "map": { "name": "Sumari Bala" }, "gamemode": "Seed", "version": "v1", "size": "1.3x1.3 km", "sizeType": "mapTexture", "numberOfCapturePoints": null, "lighting": { "name": "Sunny Mid Day", "classname": "LL_Sumari_MidDay" }, "teams": [ { "faction": "United States Army", "name": "III Corps", "tickets": 100, "commander": false, "vehicles": [ { "name": "M939 Transport", "classname": "BP_US_Util_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Transport", "classname": "BP_US_Util_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Transport", "classname": "BP_US_Util_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 0 } ], "numberOfTanks": 0, "numberOfHelicopters": 0 }, { "faction": "Russian Ground Forces", "name": "49th Combined Arms Army", "tickets": 100, "commander": false, "vehicles": [ { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 0 } ], "numberOfTanks": 0, "numberOfHelicopters": 0 } ] }, "time": "2024-11-20T06:00:21.519Z" }, { "layer": { "name": "Sumari Bala Seed v1", "classname": "Sumari_Seed_v1", "layerid": "Sumari_Seed_v1", "map": { "name": "Sumari Bala" }, "gamemode": "Seed", "version": "v1", "size": "1.3x1.3 km", "sizeType": "mapTexture", "numberOfCapturePoints": null, "lighting": { "name": "Sunny Mid Day", "classname": "LL_Sumari_MidDay" }, "teams": [ { "faction": "United States Army", "name": "III Corps", "tickets": 100, "commander": false, "vehicles": [ { "name": "M939 Transport", "classname": "BP_US_Util_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Transport", "classname": "BP_US_Util_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Transport", "classname": "BP_US_Util_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "M939 Logistics", "classname": "BP_US_Util_Desert_Logi_C", "count": 1, "spawnDelay": 0, "respawnDelay": 0 } ], "numberOfTanks": 0, "numberOfHelicopters": 0 }, { "faction": "Russian Ground Forces", "name": "49th Combined Arms Army", "tickets": 100, "commander": false, "vehicles": [ { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Transport", "classname": "BP_Kamaz_5350_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 3 }, { "name": "KamAZ 5350 Logistics", "classname": "BP_Kamaz_5350_Logi_Desert_C", "count": 1, "spawnDelay": 0, "respawnDelay": 0 } ], "numberOfTanks": 0, "numberOfHelicopters": 0 } ] }, "time": 1732082421798 } ] ```

I guess this is the culprit:

    {
        "layer": null,
        "time": "2024-11-20T18:09:08.946Z"
    },
pavelhoral commented 1 week ago

From Discord I can see that the "null" map was supposed to be Manicouagan RAAS v1 - Manicouagan (Discord timezone in the screenshot is CET / +1):

image

steelskillet commented 1 week ago

Can you provide the full log with crash. This is most likely a configuration problem and nothing is actually wrong with sjs itself.

pavelhoral commented 6 days ago

output-2024-11-20T06_00_13.204Z.log

The log contains also stringified layerHistory where DEBUG log by Palko can be seen.

image

steelskillet commented 6 days ago
[2024-11-20T06:00:15.908Z][SquadServer][1] Updating squad list...
[2024-11-20T06:00:21.633Z][SquadServer][1] Updated squad list. 
[2024-11-20T06:00:21.633Z][SquadServer][1] Updating player list...
[2024-11-20T06:00:21.695Z][SquadServer][1] Updated player list. 
[2024-11-20T06:00:21.695Z][SquadServer][1] Updating layer information... 
[2024-11-20T06:00:21.798Z][SquadServer][1] Updated layer information. 
[2024-11-20T06:00:21.798Z][SquadServer][1] Updating server information... 
[2024-11-20T06:00:21.839Z][SquadServer][1] Updated server information. 
[2024-11-20T06:00:21.839Z][LogParser][1] Attempting to watch log file... 
[2024-11-20T06:00:22.262Z][LogParser][1] Watching log file... 
[2024-11-20T06:00:22.262Z][SquadServer][1] Watching undefined... 
[2024-11-20T06:00:22.262Z][SquadServer][1] Pinging SquadJS API... 
[2024-11-20T06:00:22.419Z][SquadServer][1] Successfully pinged the SquadJS API. Got back error: Invalid ping. 
[2024-11-20T06:00:22.430Z][SquadServer][1] Fetching Admin Lists... 
[2024-11-20T06:00:22.501Z][SquadServer][1] 388 admins loaded...

As I suspected this is infact a config issue. Your squadjs is not properly connected to your log file. It should read watching <name of server> not undefined.

pavelhoral commented 6 days ago

As I suspected this is infact a config issue. Your squadjs is not properly connected to your log file. It should read watching not undefined.

This is strange. We are using SFTP log reader mode and I can confirm we are getting LogParser events (as seen in the attached log). So this works. Maybe the issue is caused by the log parser initializing before the server fully loads up (we do periodic restarts at 6 AM)? If that is the case it is a very nasty race condition.