I have a nodejs app as target endpoint in one of my api proxies. I am using
"email-templates": "^2.0.1" NPM module. It runs fine when I run with node.js runtime. But when running on trireme locally (or in edge server on-prem ver 4.15.04.00) I get below exception
TypeError: Can't use 'in' on a non-object. at nodeApp/node/node_modules/email-templates/node_modules/juice/node_modules/cheerio/lib/static.js:81 at inlineContent (nodeApp/node/node_modules/email-templates/node_modules/juice/client.js:278) at nodeApp/node/node_modules/email-templates/lib/email-template.js:132 at tryCatcher (nodeApp/node/node_modules/email-templates/node_modules/bluebird/js/main/util.js:26) at nodeApp/node/node_modules/email-templates/node_modules/bluebird/js/main/promise.js:507 at nodeApp/node/node_modules/email-templates/node_modules/bluebird/js/main/promise.js:581 at nodeApp/node/node_modules/email-templates/node_modules/bluebird/js/main/async.js:128 at nodeApp/node/node_modules/email-templates/node_modules/bluebird/js/main/async.js:133 at nodeApp/node/node_modules/email-templates/node_modules/bluebird/js/main/async.js:15 at processImmediate (timers.js:345)
cheerio static.js line # 81 is
if (Object.prototype.toString.call(dom) === '[object Object]' && !options && !('length' in dom) && !('type' in dom))
Any idea on why this is not working? When I remove && !('length' in dom) && !('type' in dom) it works fine.
@Vineet Bhatia When you locaaly run your program may be variable 'dom' is not getting created as JavaScript object. "in" will not work on non-object.
@Sonali this code is in cheerio NPM module which is an associated dependency of the email-templates NPM module I am using. The same code with exact same inputs works fine with node.js runtime. It gives this error only when running in trireme runtime.
Has anyone come across this issue?
Hard to tell what is going on. Perhaps "dom" (which is returned from a previous call to a "cheerio" function) is undefined or null. Perhaps we could start by printing the type of "dom" and see what is going on -- then we'd have to backtrack to the previous function and see what it is doing...