MCPcopy
hub / github.com/browserless/browserless / pool

Function pool

scripts/leak-check.js:65–81  ·  view source on GitHub ↗
(thunks, width = 4)

Source from the content-addressed store, hash-verified

63// so one bad request doesn't abort the wave — they're reported in the
64// final verdict instead.
65const pool = async (thunks, width = 4) => {
66 const failures = [];
67 const queue = [...thunks];
68 await Promise.all(
69 Array.from({ length: width }, async () => {
70 while (queue.length) {
71 const thunk = queue.shift();
72 try {
73 await thunk();
74 } catch (err) {
75 failures.push(String(err));
76 }
77 }
78 }),
79 );
80 return failures;
81};
82
83const drain = async (res, expectedStatuses = [200]) => {
84 // Consume the body so sockets/streams actually complete

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected