white-balloon-205
AFAIK one has toThis is no longer true actually (as of a couple releases ago).any modules inside the callback.require
How do I make instances reusable between requests then, e.g. a request with a static agent?What do you have in mind here exactly? Code that only runs once per warm-up, not once per request?
tall-librarian-49374
10/02/2018, 8:22 PMrequest
from the top of the file the other day. Yes, the code that runs once on warm-up, to reuse HTTP connections.lemon-spoon-91807
10/02/2018, 8:23 PMtall-librarian-49374
10/02/2018, 8:26 PM// do once
const http = require("http");
const httpAgent = new http.Agent({ keepAlive: true });
// do at invoke
request({ url: url, pool: httpAgent }...
lemon-spoon-91807
10/02/2018, 8:26 PMtall-librarian-49374
10/02/2018, 8:29 PMlemon-spoon-91807
10/02/2018, 8:29 PMmodule.exports = factoryFunc();
instead of module.exports = func;