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

TypeError: Can't use 'in' on a non-object - cheerio npm module in trireme #138

Open
firefoxNX opened this issue Dec 10, 2015 · 2 comments
Open

Comments

@firefoxNX
Copy link

Sorry for the cross-post from https://community.apigee.com/questions/14176/typeerror-cant-use-in-on-a-non-object-with-trireme.html

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 (version Trireme 0.8.8) 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.

@whitlockjc
Copy link
Member

Do you have a reproduction recipe? Without knowing what dom is, I have no idea how to reproduce it. Of course, using 'prop' in obj where obj is null, undefined or a non-object produces the expected output.

@danielkleinert
Copy link

Ran into the same issue. Looks like Object.prototype.toString.call(undefined) returns "[object Undefined]" in node but "[object Object]" in trireme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants