title: Make HTTP request inside Web Worker
body: <p>I am trying to use web-workers or threads in my node application for the first time. I am using the <a href="https://www.npmjs.com/package/webworker-threads" rel="nofollow">webworker-threads npm module</a>.</p>
  
  <p>Basically I would like each worker to make requests to a server, measure the response time and send it back to the main thread.</p>
  
  <p>I tried it many different ways, but I just can't seem to get it working. The basic examples from the docs work. But when I try to require a module ("request" in my case), the workers just seem to stop working, without any error messages. I saw in the docs that require doesn't work inside a worker, so I tried "importScripts()", which doesn't work either. When using threadpools I tried to use .all.eval() but it didn't work either.</p>
  
  <p>Since this is the first time working with web-workers / threads in node, I might misunderstand how to use those things in general. Here is one example I tried:</p>
  
  <p>server.js</p>
  
  <pre><code>var Worker = require('webworker-threads').Worker;
  var worker = new Worker('worker.js');
  </code></pre>
  
  <p>worker.js</p>
  
  <pre><code>console.log("before import");
  importScripts('./node_modules/request/request.js');
  console.log("after import");
  </code></pre>
  
  <p>This basic example only prints <code>before import</code> and then stops.</p>