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

Error spotted: TypeError: Cannot read property 'event' of null #13

Open
Captaindando opened this issue Sep 1, 2021 · 6 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@Captaindando
Copy link

I'm getting an error when attempting to log 'say', 'say_team' and 'kill' signals.
am I doing something wrong? I've included my code at the end.

����log L 09/01/2021 - 07:55:32: "monkey<1><STEAM_ID_LAN><1>" say "lkjasldjsa"

Error spotted: TypeError: Cannot read property 'event' of null
Error spotted:  TypeError: Cannot read property 'event' of null
    at D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:58:36
    at Array.forEach (<anonymous>)
    at HLDS_Log.regexSearch (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:55:24)
    at Socket.<anonymous> (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:44:18)
    at Socket.emit (events.js:321:20)
    at UDP.onMessage [as onmessage] (dgram.js:924:8)
log L 09/01/2021 - 08:14:15: "ryuichi<8>" killed "Billy<10>" with 9mmhandgun

Error spotted: TypeError: Cannot read property 'event' of null
Error spotted:  TypeError: Cannot read property 'event' of null
    at D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:58:36
    at Array.forEach (<anonymous>)
    at HLDS_Log.regexSearch (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:55:24)
    at Socket.<anonymous> (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:44:18)
    at Socket.emit (events.js:321:20)
    at UDP.onMessage [as onmessage] (dgram.js:924:8)

/*jshint esversion: 6 */

const {HLDS_Log}= require('hlds-log');
//const {HLDS_Log} = require('../lib/app');

logger = new HLDS_Log(3000, true);

// Start logger
logger.start();

// Increase listeners limit to avoid warning
logger.setMaxListeners(15);

logger.once('hlds_connect', (info) => {
    console.log('Server connected!' + info.address);
});

logger.on('kill', info =>{
    console.log(info);
});

logger.on('raw', raw => {
    console.log(raw);
});

logger.on('say_team', info => {
    console.log(info);
});

logger.on('say', info => {
    console.log(info);
}); 

logger.on('join', info => {
    console.log(info);
});

logger.on('leave', info => {
    console.log(info);
});

logger.on('enter', info => {
    console.log(info);
});

logger.on('end_score', info => {
    console.log(info);
});

logger.on('player_action', info => {
    console.log(info);
});

logger.on('server_action', info => {
    console.log(info);
});

logger.on('round_end', info => {
    console.log(info);
});

logger.on('connect', info => {
    console.log(info);
});

logger.on('map_change', info => {
    console.log(info);
});

logger.on('map_start', info => {
    console.log(info);
});

logger.on('suicide', info => {
    console.log(info);
});

logger.on('shutdown', info => {
    console.log(info);
});

logger.on('log_off', info => {
    console.log(info);
});

logger.on('cvarsDone', info => {
    console.log(info);
});

logger.on('kick', info => {
    console.log(info);
});

logger.on('error', error =>{
    console.log('Error spotted: ', error)
})
@kallefrombosnia kallefrombosnia added the bug Something isn't working label Sep 1, 2021
@kallefrombosnia
Copy link
Owner

Hello, which game server version do you use, HLDS or ReHLDS or something else? I will take a look into this later.

@Captaindando
Copy link
Author

Hi Kalle, I'm using hlds with these parameters: -game jumbot -console +map crossfire +maxplayers 16
I'm using jumbot to test it out, but I've received the same errors without it. the node app is hosted on the same computer I'm hosting the half life server and I point my log to localhost with a port of 3000 if that helps

just wanted to thank you for developing this, it's a massive help

@kallefrombosnia
Copy link
Owner

Hello, I debugged this and found out that your arriving string is malformed.

Examples:

⌂⌂⌂⌂log L 09/01/2021 - 19:31:18: "kalle<1><STEAM_ID_LAN><TERRORIST>" killed "VATB | Jackson_<10><BOT><CT>" with "deagle"

log L 09/01/2021 - 08:14:15: "ryuichi<8>" killed "Billy<10>" with 9mmhandgun

⌂⌂⌂⌂log L 09/01/2021 - 19:34:49: "kalle<1><STEAM_ID_LAN><TERRORIST>" say "say"

����log L 09/01/2021 - 07:55:32: "monkey<1><STEAM_ID_LAN><1>" say "lkjasldjsa"

Obviously, there is a difference, so that's why it fails. Try with the cstrike game parameter and give us the results.

@kallefrombosnia kallefrombosnia self-assigned this Sep 1, 2021
@Captaindando
Copy link
Author

Hi Kalle, I tested it out with the parameter you asked for and here are the results:

'say' works in this case, along with almost every other log, The only error I found was on 'Dropped_The_Bomb'

����log L 09/02/2021 - 07:50:37: "Player<1><STEAM_ID_LAN><TERRORIST>" say "laskjdlkjasl"

{
  event: 'say',
  player: {
    name: 'Player',
    id: '1',
    steamid: 'STEAM_ID_LAN',
    side: 'TERRORIST',
    message: 'laskjdlkjasl'
  },
  time: { ss: '37', mm: '50', hh: '07' },
  date: { dd: '02', mm: '09', yy: '2021' }
}
����log L 09/02/2021 - 07:50:52: "Player<-1><><TERRORIST>" triggered "Dropped_The_Bomb"

Error spotted: TypeError: Cannot read property 'event' of undefined
Error spotted:  TypeError: Cannot read property 'event' of undefined
    at D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:58:36
    at Array.forEach (<anonymous>)
    at HLDS_Log.regexSearch (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:55:24)
    at Socket.<anonymous> (D:\Google Drive\Half Life Modding\backend app\node_modules\hlds-log\lib\functions.js:44:18)
    at Socket.emit (events.js:321:20)
    at UDP.onMessage [as onmessage] (dgram.js:924:8)

@Captaindando
Copy link
Author

Captaindando commented Sep 2, 2021

I think I've found what's causing the errors. It's in the name
I started a Half-life game and made it a team game and the errors didn't show up

log L 09/02/2021 - 08:08:38: "Player<1><STEAM_ID_LAN><robo>" say_team "dslfkjkl"

{
  event: 'say_team',
  player: {
    name: 'Player',
    id: '1',
    steamid: 'STEAM_ID_LAN',
    side: 'robo',
    message: 'dslfkjkl'
  },

In instances where it's a free for all, or if there is a player-caused log entry that is missing a part, it throws an error, for example, lines like these:

log L 09/02/2021 - 07:59:54: "Player<1><STEAM_ID_LAN><1>" say "lakjslkdja" - Half-life DM with no teams
log L 09/02/2021 - 07:50:52: "Player<-1><><TERRORIST>" triggered "Dropped_The_Bomb" - Cstrike, the middle 'STEAM_ID_LAN' is missing

@kallefrombosnia
Copy link
Owner

Yup, I see where the problem lies. This was tested cstrike only game mode so it fails on other game modes which have their own custom log messages.
I will move this from bug to enchantment since I plan on adding a custom class constructor parameter which will be used to determine incoming string type and use the proper parser for it.

@kallefrombosnia kallefrombosnia added enhancement New feature or request and removed bug Something isn't working labels Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants