I found this excellent suggestion about improved error tracing when loading Nodes themselves, but it turns out that loading the Node isn't when my issue happens.
By adding the following to logging section of settings.js like this:
callstack: {
level: 'error',
metrics: false,
handler: function(conf) {
return function(msg) {
e = new Error();
console.error(e.stack);
// console.trace();
}
}
}
I was able to see this (still not far enough to find the underlying problem):
24 Aug 12:38:05 - [error] [alexa-remote-account:c969cb45.22f3d8] Invalid or unexpected token
Error
at LogHandler.handler (/var/www/.node-red/settings.js:256:25)
at LogHandler.<anonymous> (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/log.js:66:18)
at LogHandler.emit (events.js:400:28)
at /usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/log.js:160:21
at Array.forEach (<anonymous>)
at Object.log (/usr/lib/node_modules/node-red/node_modules/@node-red/util/lib/log.js:159:21)
at Object.log (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/index.js:739:19)
at Flow.log (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:128:21)
at log_helper (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:498:16)
at AlexaRemoteAccountNode.Node.error (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/Node.js:527:9)
But combining Bart's idea with the Node.js file mentioned in this last callstack, I was finally able to see where this cryptic error is raised by adding console.error(msg) above this line. Would be be helpful I think to add this as well as Bart's suggestion to the master branch.