rchipka / node-osmosis

Web scraper for NodeJS
4.11k stars 245 forks source link

RangeError: Maximum call stack size exceeded #198

Open statickidz opened 6 years ago

statickidz commented 6 years ago

I'm getting this error randomly when I scrap some sites with cloudscraper (cloudflare scraper) and I parse the HTML with osmosis, can you guide me in this?

CODE:

const osmosis = require('osmosis')
const cloudscraper = require('cloudscraper')

const url = 'https://example.com' // it happend in different urls

cloudscraper.get(url, (error, response, body) => {
      try {
        osmosis
        .parse(body)
        .set({
          info: '.coin-information:eq(2)'
        })
        .data(async data=> {
          // process data.info
          Logger.info('TASK: success')
        })
      } catch(error) {
        console.error('TASK: error', error)
      }
    })

ERROR:

RangeError: Maximum call stack size exceeded at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:517:45) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) at Command.findCommandArg (/app/node_modules/osmosis/lib/Command.js:533:37) my-server app[web] info events.js:121 listeners[i].call(self, arg1); ^ my-server app[web] info my-server app[web] info TypeError: listeners[i].call is not a function at emitOne (events.js:121:20) at TLSSocket.emit (events.js:211:7) at _handle.close (net.js:554:12) at TCP.done [as _onclose] (_tls_wrap.js:356:7)

EliuX commented 4 years ago

I had the same problem and I realized I was having a cyclic call. I changed that and it was solved! Probably, you are having the same cyclic issue. Check out what happens in these lines of your code:

my-server app[web] info events.js:121
listeners[i].call(self, arg1);
^
my-server app[web] info
my-server app[web] info TypeError: listeners[i].call is not a function