html-metadata
html-metadata copied to clipboard
TypeError: result.isFulfilled is not a function
Full error dump:
TypeError: result.isFulfilled is not a function at /home/bubs/BotMark/node_modules/html-metadata/lib/index.js:34:26 at runCallback (timers.js:637:20) at tryOnImmediate (timers.js:610:5) at processImmediate [as _immediateCallback] (timers.js:582:5) From previous event: at Object.exports.parseAll (/home/bubs/BotMark/node_modules/html-metadata/lib/index.js:30:4) at Request.
(/home/bubs/BotMark/node_modules/html-metadata/index.js:31:16) at Request.self.callback (/home/bubs/BotMark/node_modules/request/request.js:186:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/home/bubs/BotMark/node_modules/request/request.js:1081:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at Gunzip. (/home/bubs/BotMark/node_modules/request/request.js:1001:12) at Gunzip.g (events.js:291:16) at emitNone (events.js:91:20) at Gunzip.emit (events.js:185:7)
Tried both promise -based and callback based
Example calling code
htmlMetadata('http://www.google.com', (err, metadata)=> { if (err) { debug('Scraper html-metadata failed! ', err); } else { debug('Html-metadata returned: ', metadata); } });
Tried this module a few months ago and it worked just fine. Is there something wrong with the latest release?
I can take a look at this (accepted the task in Google CodeIn 2016 😉). Can you maybe tell me what version of node and npm you're using? Just run node --version
and npm --version
.
Also, I'm just going to assume that debug()
is a variant of console.log()
or console.error()
.
$ node --version v6.9.4
$ npm --version 3.10.10
And yes, sorry , debug just handles/displays to console Let me know if I can be of any help or you need more info.
Thanks.
I'm having trouble reproducing this bug. Here's the versions of everything I've tested it on:
Windows 10 Home x64
==========
- Node v6.8.1 & npm v3.3.11
Ubuntu 14.04.5 LTS
==========
- Node v4.7.2 & npm v2.15.11
- Node v6.9.4 & npm v3.10.10
- Node v7.4.0 & npm v4.0.5
Here's the code that I used for my testing:
const htmlMetadata = require('html-metadata');
function testCallbackBased() {
htmlMetadata('http://www.google.com', (err, metadata) => {
if (err) {
console.error('[testCallbackBased]: Scraper html-metadata failed! ', err);
}
else {
console.log('[testCallbackBased]: html-metadata returned: ', metadata);
}
});
}
function testPromiseBased() {
htmlMetadata('http://www.google.com')
.then((m) => console.log('[testPromiseBased]: html-metadata returned: ', m))
.catch((e) => console.error('[testPromiseBased]: Scraper html-metadata failed! ', e));
}
testCallbackBased();
testPromiseBased();
In all scenarios, the above code produces output like this:
$ node .
(node:13152) DeprecationWarning: parse() is deprecated, use toJson()
[testPromiseBased]: html-metadata returned: { general: { title: 'Google', lang: 'en-CA' },
openGraph:
{ description: 'Sandford Fleming’s 190th Birthday! #GoogleDoodle',
image:
{ url: 'http://www.google.com/logos/doodles/2017/sandford-flemings-190th-birthday-5693910618734592.2-thp.png',
width: '519',
height: '230' } },
schemaOrg: { items: [ [Object] ] } }
[testCallbackBased]: html-metadata returned: { general: { title: 'Google', lang: 'en-CA' },
openGraph:
{ description: 'Sandford Fleming’s 190th Birthday! #GoogleDoodle',
image:
{ url: 'http://www.google.com/logos/doodles/2017/sandford-flemings-190th-birthday-5693910618734592.2-thp.png',
width: '519',
height: '230' } },
schemaOrg: { items: [ [Object] ] } }
This is all with html-metadata
at the lastest commit (958991baeaa1f35c973e9eaf8a5edb6b31d8ed5f) and at v1.6.2
.
I've honestly got no idea what's going on here - I looked at all the files mentioned in your stacktrace, and I can't find any issues. Did you maybe want to try reinstalling html-metadata
? Or do you have a repo that I can look at?
Hey @brezuicabogdan, so I chatted with @mvolz and we think that since no one can reproduce this issue we might have to close it... Sorry 😓
I'd still be totally willing to help you with this problem whenever you want - it just doesn't seem to be thus module's fault.
Again, sorry about this!
It's on @jo12bar , I am a developer I know how this works. I only submitted this bug report because I know bugs are important to developers and I would like people to do this for me too. I managed to resolve my problem with another module for not and I will get back to html-metadata as soon as I find the time. I will try to find the problem myself but I am not very experienced with NodeJs (I'm a PHP developer myself). I will send you a PM if I need help. Thanks for everything.
Hi all, I am not experiences in how to contribute in such an open source project.
But I stumpled on this error, and it seems to be caused by line 31 in lib/index.js where a for of loop is used. This will at least in my version of node (v10.16.3) result in custom functions on the Array object together with the actual entries. Thus if one has a custom function on the array prototype, this will fail.
The solution is to use Object.keys(results) instead, or any other means that do not include the prototype functions.
I hope it helps, my local copy is patched and it works wonderfully:-)
Cheers Mads