title: r rvest error: "Error in doc_namespaces(doc) : external pointer is not valid"
body: <p>My question is similar to <a href="https://stackoverflow.com/questions/51159150/r-web-scraping-through-multiple-urls-with-rvest-and-purrr">this one</a>, but the latter did not receive an answer I can work with. I am scraping thousands of urls with <code>xml2::read_html</code>. This works fine. But when I try and parse the resulting html documents using <code>purrr::map_df</code> and <code>html_nodes</code>, I get the following error:</p>
  
  <pre><code>Error in doc_namespaces(doc) : external pointer is not valid
  </code></pre>
  
  <p>For some reason, I am unable to reproduce the error using examples. The example below is not good, because it works totally fine. But if someone could explain me conceptually what the error means and how to solve it, that would be great (here is a <a href="https://github.com/HenrikBengtsson/future.apply/issues/4" rel="nofollow noreferrer">github thread</a> on a similar problem, but I don't follow all the technicalities). </p>
  
  <pre><code>library(rvest)
  library(purrr)
  urls_test &lt;- list("https://en.wikipedia.org/wiki/FC_Barcelona",
               "https://en.wikipedia.org/wiki/Rome")
  h &lt;- urls_test %&gt;% map(~{
    Sys.sleep(sample(seq(1, 3, by=0.001), 1))
    read_html(.x)})
  out &lt;- h %&gt;% map_df(~{
    a &lt;- html_nodes(., "#firstHeading") %&gt;% html_text()
    a &lt;- if (length(a) == 0) NA else a
    b &lt;- html_nodes(., ".toctext") %&gt;% html_text()
    b &lt;- if (length(b) == 0) NA else b
  
    df &lt;- tibble(a, b)
  })
  </code></pre>
  
  <p>Session info:</p>
  
  <pre><code>&gt; sessionInfo()
  R version 3.6.0 (2019-04-26)
  Platform: x86_64-pc-linux-gnu (64-bit)
  Running under: Devuan GNU/Linux ascii
  </code></pre>