Error Handling Confusion..

#1

Hi,

If I run this javascript file with node:
testy = function () {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};
testy();
I get a TypeError which I would expect:

$ node autobahn_test2.js
Connection opened

/home/asbo/autobahn_test2.js:5
var f = d.bill.jill;
^
TypeError: Cannot read property ‘jill’ of undefined
at testy (/home/asbo/autobahn_test2.js:5:17)
at Object. (/home/asbo/autobahn_test2.js:9:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

But using autobahn:
var autobahn = require(‘autobahn’);

var connection = new autobahn.Connection({
url: ‘ws://127.0.0.1:8080/ws’,
realm: ‘realm1’
});

connection.onopen = function (session) {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};

connection.open();

There is no error, and the process doesn’t exit:
$ node autobahn_test.js
Connection opened

I would expect this to exit in the same way. Since the ‘Bye now’ statement isn’t printed, clearly the execution is being stopped by the error, just that the error isn’t being shown.

Is this expectation wrong, or am I doing something wrong, or something else?

Any help appreciated.

Cheers

Mike

0 Likes

#2

In case this helps anyone else:

Setting gobal variable AUTOBAHN_DEBUG = true seeems to be the answer - thanks to the hint here
https://github.com/tavendo/AutobahnJS/issues/117

The Autobahn webpage only shows this for browswer side:
http://autobahn.ws/js/reference.html?highlight=debug#debug-mode

So keys seem to be (a) Global variable and (b) Before autobahn code is included.

Repeating my original example but with

AUTOBAHN_DEBUG = true;

I now see:

AutobahnJS debug enabled
trying to create WAMP transport of type: websocket
using WAMP transport type: websocket
Connection opened
Exception raised from app code while firing Connection.onopen() [TypeError: Cannot read property 'jill' of undefined]

Which is exactly what I wanted

Cheers

Mike

···

On Tuesday, October 7, 2014 at 7:07:54 AM UTC+1, Mike Raistrick wrote:

Hi,

If I run this javascript file with node:
testy = function () {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};
testy();
I get a TypeError which I would expect:

$ node autobahn_test2.js
Connection opened

/home/asbo/autobahn_test2.js:5
var f = d.bill.jill;
^
TypeError: Cannot read property ‘jill’ of undefined
at testy (/home/asbo/autobahn_test2.js:5:17)
at Object. (/home/asbo/autobahn_test2.js:9:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

But using autobahn:
var autobahn = require(‘autobahn’);

var connection = new autobahn.Connection({
url: ‘ws://127.0.0.1:8080/ws’,
realm: ‘realm1’
});

connection.onopen = function (session) {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};

connection.open();

There is no error, and the process doesn’t exit:
$ node autobahn_test.js
Connection opened

I would expect this to exit in the same way. Since the ‘Bye now’ statement isn’t printed, clearly the execution is being stopped by the error, just that the error isn’t being shown.

Is this expectation wrong, or am I doing something wrong, or something else?

Any help appreciated.

Cheers

Mike

0 Likes

#3

Hi Mike!

I’ve updated the Autobahn|JS documentation to make it clear that debug mode works both in the browser and in Node.js.

Regards,

Alex

···

Am Samstag, 21. Februar 2015 11:20:35 UTC+1 schrieb motosota:

In case this helps anyone else:

Setting gobal variable AUTOBAHN_DEBUG = true seeems to be the answer - thanks to the hint here
https://github.com/tavendo/AutobahnJS/issues/117

The Autobahn webpage only shows this for browswer side:
http://autobahn.ws/js/reference.html?highlight=debug#debug-mode

So keys seem to be (a) Global variable and (b) Before autobahn code is included.

Repeating my original example but with

AUTOBAHN_DEBUG = true;

I now see:

AutobahnJS debug enabled
trying to create WAMP transport of type: websocket
using WAMP transport type: websocket
Connection opened
Exception raised from app code while firing Connection.onopen() [TypeError: Cannot read property 'jill' of undefined]


Which is exactly what I wanted

Cheers

Mike

On Tuesday, October 7, 2014 at 7:07:54 AM UTC+1, Mike Raistrick wrote:

Hi,

If I run this javascript file with node:
testy = function () {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};
testy();
I get a TypeError which I would expect:

$ node autobahn_test2.js
Connection opened

/home/asbo/autobahn_test2.js:5
var f = d.bill.jill;
^
TypeError: Cannot read property ‘jill’ of undefined
at testy (/home/asbo/autobahn_test2.js:5:17)
at Object. (/home/asbo/autobahn_test2.js:9:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

But using autobahn:
var autobahn = require(‘autobahn’);

var connection = new autobahn.Connection({
url: ‘ws://127.0.0.1:8080/ws’,
realm: ‘realm1’
});

connection.onopen = function (session) {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};

connection.open();

There is no error, and the process doesn’t exit:
$ node autobahn_test.js
Connection opened

I would expect this to exit in the same way. Since the ‘Bye now’ statement isn’t printed, clearly the execution is being stopped by the error, just that the error isn’t being shown.

Is this expectation wrong, or am I doing something wrong, or something else?

Any help appreciated.

Cheers

Mike

0 Likes

#4

Thanks Alex,

would it be possible to note somewhere (debug section or an error handling section) that debug mode is needed to see runtime or user thrown exceptions within .onopen and .onclose functions?

That knowledge was the main thing I was missing - (and I think is the point in https://github.com/tavendo/AutobahnJS/issues/117).

Thanks again!

Mike

···

On Sat, Feb 21, 2015 at 10:53 AM, Alexander Gödde alexande...@googlemail.com wrote:

Hi Mike!

I’ve updated the Autobahn|JS documentation to make it clear that debug mode works both in the browser and in Node.js.

Regards,

Alex

Am Samstag, 21. Februar 2015 11:20:35 UTC+1 schrieb motosota:

In case this helps anyone else:

Setting gobal variable AUTOBAHN_DEBUG = true seeems to be the answer - thanks to the hint here
https://github.com/tavendo/AutobahnJS/issues/117

The Autobahn webpage only shows this for browswer side:
http://autobahn.ws/js/reference.html?highlight=debug#debug-mode

So keys seem to be (a) Global variable and (b) Before autobahn code is included.

Repeating my original example but with

AUTOBAHN_DEBUG = true;

I now see:

AutobahnJS debug enabled
trying to create WAMP transport of type: websocket
using WAMP transport type: websocket
Connection opened
Exception raised from app code while firing Connection.onopen() [TypeError: Cannot read property 'jill' of undefined]


Which is exactly what I wanted

Cheers

Mike

On Tuesday, October 7, 2014 at 7:07:54 AM UTC+1, Mike Raistrick wrote:

Hi,

If I run this javascript file with node:
testy = function () {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};
testy();
I get a TypeError which I would expect:

$ node autobahn_test2.js
Connection opened

/home/asbo/autobahn_test2.js:5
var f = d.bill.jill;
^
TypeError: Cannot read property ‘jill’ of undefined
at testy (/home/asbo/autobahn_test2.js:5:17)
at Object. (/home/asbo/autobahn_test2.js:9:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

But using autobahn:
var autobahn = require(‘autobahn’);

var connection = new autobahn.Connection({
url: ‘ws://127.0.0.1:8080/ws’,
realm: ‘realm1’
});

connection.onopen = function (session) {
console.log(‘Connection opened’);
var d = {};
var e = d.bill;
var f = d.bill.jill;
console.log(‘Bye now…’)
};

connection.open();

There is no error, and the process doesn’t exit:
$ node autobahn_test.js
Connection opened

I would expect this to exit in the same way. Since the ‘Bye now’ statement isn’t printed, clearly the execution is being stopped by the error, just that the error isn’t being shown.

Is this expectation wrong, or am I doing something wrong, or something else?

Any help appreciated.

Cheers

Mike

You received this message because you are subscribed to the Google Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.

To post to this group, send email to autob...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/13459280-1a80-4f3d-8b36-2535fc612d24%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#5

I’ve tried the global AUTOBAHN_DEBUG but it does not seem to be honoured in the callback for a registered procedure. Consider this example:

session.register(‘com.example.error’, function (args, kwargs, details) {

require('./i-got-the-path-wrong');

});

and this reported back:

 Error: done() invoked with non-Error: {"error":"wamp.error.runtime_error","args":["MODULE_NOT_FOUND"],"kwargs":{}}

However, nothing showed in the Crossbar console.

Is it possible for Authobahn(JS) to include a stack trace so it’s easier to pinpoint the error?

Thanks in advance.

Regards,

Andrew Eddie

0 Likes

#6

Hi Andrew!

Making debugging easier is something we’re working on (there have been big improvements to logging recently) - and input here is always welcome.

Could you please file an issue in the revelant repository/ies (https://github.com/crossbario / https://github.com/tavendo/AutobahnJS) stating your use case and what log output you’d like?

I can’t promise anything (especially not a timeline), but we’ll take your input under consideration.

Regards,

Alex

···

Am Freitag, 10. Juli 2015 04:21:00 UTC+2 schrieb Andrew Eddie:

I’ve tried the global AUTOBAHN_DEBUG but it does not seem to be honoured in the callback for a registered procedure. Consider this example:

session.register(‘com.example.error’, function (args, kwargs, details) {

require('./i-got-the-path-wrong');

});

and this reported back:

 Error: done() invoked with non-Error: {"error":"wamp.error.runtime_error","args":["MODULE_NOT_FOUND"],"kwargs":{}}

However, nothing showed in the Crossbar console.

Is it possible for Authobahn(JS) to include a stack trace so it’s easier to pinpoint the error?

Thanks in advance.

Regards,

Andrew Eddie

0 Likes