{"action":"closed","issue":{"url":"https://api.github.com/repos/assaf/zombie/issues/953","labels_url":"https://api.github.com/repos/assaf/zombie/issues/953/labels{/name}","comments_url":"https://api.github.com/repos/assaf/zombie/issues/953/comments","events_url":"https://api.github.com/repos/assaf/zombie/issues/953/events","html_url":"https://github.com/assaf/zombie/issues/953","id":111929695,"number":953,"title":"AssertionError: No open window with an HTML document","user":{"login":"rahul-desai3","id":2539881,"avatar_url":"https://avatars.githubusercontent.com/u/2539881?v=3","gravatar_id":"","url":"https://api.github.com/users/rahul-desai3","html_url":"https://github.com/rahul-desai3","followers_url":"https://api.github.com/users/rahul-desai3/followers","following_url":"https://api.github.com/users/rahul-desai3/following{/other_user}","gists_url":"https://api.github.com/users/rahul-desai3/gists{/gist_id}","starred_url":"https://api.github.com/users/rahul-desai3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rahul-desai3/subscriptions","organizations_url":"https://api.github.com/users/rahul-desai3/orgs","repos_url":"https://api.github.com/users/rahul-desai3/repos","events_url":"https://api.github.com/users/rahul-desai3/events{/privacy}","received_events_url":"https://api.github.com/users/rahul-desai3/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-16T23:34:13Z","updated_at":"2015-10-18T23:38:41Z","closed_at":"2015-10-18T23:38:41Z","body":"While I was crawling & scrapping http://www.mesotheliomagroup.com/ completely, my script terminated with an error while scrapping this particular webpage: http://www.mesotheliomagroup.com/treatment/chemotherapy/drugs/carboplatin#side-effects\r\n\r\nIt had crawled and scrapped 63% of all the pages by that time.\r\n\r\nHere is the error that I got:\r\n\r\n```\r\n/Users/rahuldesai/nightmare/node_modules/zombie/lib/eventloop.js:594\r\n            throw error;\r\n            ^\r\nAssertionError: No open window with an HTML document\r\n    at Browser.queryAll (/Users/rahuldesai/nightmare/node_modules/zombie/lib/index.js:460:7)\r\n    at /Users/rahuldesai/nightmare/index.js:67:20\r\n    at done (/Users/rahuldesai/nightmare/node_modules/zombie/lib/eventloop.js:589:11)\r\n    at timeout (/Users/rahuldesai/nightmare/node_modules/zombie/lib/eventloop.js:601:33)\r\n    at Timer.listOnTimeout (timers.js:89:15)\r\n```\r\n\r\nHere is what my code looks like:\r\n\r\n```\r\nconst Browser = require('zombie');  // to grab the HTML from URL\r\nvar Url = require(\"url\");  // for parsing URLs\r\n\r\nvar emailAddresses = [], \r\n\tlinks = [], \r\n\tseen = [],\r\n\terrors = [],\r\n\tindex = 0;\r\n\r\nconst browser = new Browser();\r\n\r\nvar testDomain = 'http://www.mesotheliomagroup.com/';\r\n\r\nlinks.push(testDomain);  // just to start with\r\n\r\n\r\nfunction scrapAndCrawl(links){\r\n\tvar testLink = links[index];\r\n\r\n\tconsole.log('Crawling page # ' + index);\r\n\tconsole.log('Total links = ' + links.length);\r\n\tconsole.log((links.length - index) + ' more link(s) to crawl.');\r\n\tconsole.log('*** PROGRESS = ' + Math.floor(index/links.length*100) + ' %');\r\n\tconsole.log('Email addresses found so far: ', emailAddresses);\r\n\tconsole.log('Now Crawling: ' + testLink);\r\n\r\n\tif(!seen[testLink]){\r\n\t\t// get HTML\r\n\t\tbrowser.visit(testLink, function() {\r\n\r\n\t\t\tseen[testLink] = true;\r\n\r\n\t\t\tvar htmlString = browser.html();\r\n\r\n\t\t\t// filter all <a>'s\r\n\t\t\tvar a = browser.queryAll(\"a\").map(function (node) {\r\n\r\n\t\t\t\tvar href = node.href;\r\n\r\n\t\t\t\tif(href){\r\n\r\n\t\t\t\t\thref = href.trim();\r\n\r\n\t\t\t\t\thref = Url.resolve(testLink, href);\r\n\t\t\t\t\t\r\n\t\t\t\t\tif(href.indexOf(testDomain) === 0 && // href has testDomain in it\r\n\t\t\t\t\t\t/\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b/gi.test(href) === false && // href is not an email\r\n\t\t\t\t\t\tlinks.indexOf(href) === -1 &&  // not in links yet\r\n\t\t\t\t\t\t!seen[href]){  // href is not seen yet\r\n\r\n\t\t\t\t\t\t\t// console.log('Found an eligible and unique link: ' + href);\r\n\t\t\t\t\t\t\tlinks.push(href);\r\n\r\n\t\t\t\t\t\t\tnewLinksNum++;\r\n\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// console.log('Ignored: ' + href);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn href;\r\n\t\t\t});\r\n\r\n\t\t\tconsole.log('Found ' + newLinksNum + ' new links.');\r\n\t\t\tconsole.log('Total links = ' + links.length);\r\n\t\t\tconsole.log('links seen = ' + Object.size(seen));  // .size() defined later in the script\r\n\r\n\t\t\tif(index !== links.length-1){\r\n\t\t\t\tconsole.log('Crawling next webpage...');\r\n\t\t\t\tindex++;\r\n\t\t\t\tscrapAndCrawl(links);\r\n\t\t\t} else {\r\n\t\t\t\tconsole.log('scrapAndCrawl COMPLETE!');\r\n\t\t\t\tconsole.log('Updated array of emails', emailAddresses);\r\n\t\t\t\tconsole.log('Found total ' + emailAddresses.length + ' emailAddresses.');\r\n\r\n\t\t\t\tlinks.sort(function (a, b){\r\n\t\t\t\t\treturn a.localeCompare(b);\r\n\t\t\t\t});\r\n\t\t\t\t\r\n\t\t\t\tconsole.log('Links crawled: ', links);\r\n\t\t\t\tconsole.log('Total links crawled: ', links.length);\r\n\t\t\t\tconsole.log('Errors: ', errors);\r\n\r\n\t\t\t\tconsole.log('ALL SET!');\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t} else {\r\n\r\n\t\tconsole.log('Seen already: ' + testLink);\r\n\r\n\t\tif(index !== links.length-1){\r\n\t\t\tconsole.log('Crawling next webpage...');\r\n\t\t\tindex++;\r\n\t\t\tscrapAndCrawl(links);\r\n\t\t} else {\r\n\t\t\tconsole.log('scrapAndCrawl COMPLETE!');\r\n\t\t\tconsole.log('Updated array of emails', emailAddresses);\r\n\t\t\tconsole.log('Found total ' + emailAddresses.length + ' emailAddresses.');\r\n\r\n\t\t\tlinks.sort(function (a, b){\r\n\t\t\t\treturn a.localeCompare(b);\r\n\t\t\t});\r\n\t\t\t\r\n\t\t\tconsole.log('Links crawled: ', links);\r\n\t\t\tconsole.log('Total links crawled: ', links.length);\r\n\t\t\tconsole.log('Errors: ', errors);\r\n\r\n\t\t\tconsole.log('ALL SET!');\r\n\t\t}\r\n\r\n\t}\r\n}\r\n\r\nscrapAndCrawl(links);\r\n```\r\n\r\nPreviously, it got stuck at another URL. I tested a couple of other domains and it did not give me any such issues.\r\n\r\nI am using Node.js v4.1.1 on OSX Yosemite 10.10.5\r\n\r\nHow do I fix this?"}}