Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Avoid exit on AssertionError #70

@leo-combes

Description

@leo-combes

I have an a problem with errors caused with malformated packets. We are using autobahn and native-snmp as service or module running on it.
In these cases, when an AssertionError is raised, the module exits as if an exception was ocurred, stopping it all.

2018-05-21T12:20:58-0300 [Guest       25380] Woops! An error occurred while parsing an SNMP message. :(
2018-05-21T12:20:58-0300 [Guest       25380] To have this problem corrected, please report the information below verbatim
2018-05-21T12:20:58-0300 [Guest       25380] via email to snmp@nym.se or by creating a GitHub issue at
2018-05-21T12:20:58-0300 [Guest       25380] https://github.com/calmh/node-snmp-native/issues
2018-05-21T12:20:58-0300 [Guest       25380] Thanks!
2018-05-21T12:20:58-0300 [Guest       25380] AssertionError: false == true
2018-05-21T12:20:58-0300 [Guest       25380] at parse (/var/www/project/wampServer/node_modules/snmp-native/lib/snmp.js:236:12)
2018-05-21T12:20:58-0300 [Guest       25380] at EventEmitter.msgReceived (/var/www/project/wampServer/node_modules/snmp-native/lib/snmp.js:416:15)
2018-05-21T12:20:58-0300 [Guest       25380] at emitTwo (events.js:106:13)
2018-05-21T12:20:58-0300 [Guest       25380] at Socket.emit (events.js:191:7)
2018-05-21T12:20:58-0300 [Guest       25380] at UDP.onMessage (dgram.js:549:8)
2018-05-21T12:20:58-0300 [Guest       25380] Message data:
2018-05-21T12:20:58-0300 [Guest       25380] 30 82 00 38 02 01 01 04 81 06 70 75 62 6c 69 63
2018-05-21T12:20:58-0300 [Guest       25380] a2 82 00 28 02 04 28 32 78 01 02 01 00 02 01 00
2018-05-21T12:20:58-0300 [Guest       25380] 30 82 00 18 30 82 00 14 06 82 00 08 2b 06 01 02
2018-05-21T12:20:58-0300 [Guest       25380] 01 01 03 00 43 82 00 04 01 4d ce af
2018-05-21T12:20:58-0300 [Guest       25380] events.js:160
2018-05-21T12:20:58-0300 [Guest       25380] throw er; // Unhandled 'error' event
2018-05-21T12:20:58-0300 [Guest       25380] ^
2018-05-21T12:20:58-0300 [Guest       25380] AssertionError: false == true
2018-05-21T12:20:58-0300 [Guest       25380] at parse (/var/www/project/wampServer/node_modules/snmp-native/lib/snmp.js:236:12)
2018-05-21T12:20:58-0300 [Guest       25380] at EventEmitter.msgReceived (/var/www/project/wampServer/node_modules/snmp-native/lib/snmp.js:416:15)
2018-05-21T12:20:58-0300 [Guest       25380] at emitTwo (events.js:106:13)
2018-05-21T12:20:58-0300 [Guest       25380] at Socket.emit (events.js:191:7)
2018-05-21T12:20:58-0300 [Guest       25380] at UDP.onMessage (dgram.js:549:8)
2018-05-21T12:20:58-0300 [Controller  25341] Guest worker-005 exited with error A process has ended with a probable error condition: process ended with exit code 1.

I could fix it if, instead stop with an AssertionError, the module would continue its execution and only returning an error in the response.

sessionSnmp.get({ oid: getIdOid }, function(error, varbinds){
	if(error) {				// <--- I would like see the error here
		logger.error("error!");
		logger.error(error.toString());
		result.errorDescription = error.toString();
		d.resolve(result);
	} else {     
		try{
			result.uptime = varbinds[0].value;
			result.error = 'false';
			d.resolve(result);        
		}
		catch(e){			// <--- ...or here
			logger.error(e);
			result.errorDescription = e;
			d.resolve(result);
		}
	}
});

How I could do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions