Skip to content

Commit c0fa009

Browse files
authored
fix: attempt to fix unavailable resources (#444)
Change the `acquireAndRelease` function to utilize the built-in `use` function of the generic pool module
1 parent b521f94 commit c0fa009

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,7 @@ const pptrPool = genericPool.createPool(
115115

116116
const acquireAndRelease = async <T>(
117117
callback: (browser: puppeteer.Browser) => Promise<T>,
118-
): Promise<T> => {
119-
const browser = await pptrPool.acquire();
120-
try {
121-
const res = await callback(browser);
122-
await pptrPool.release(browser);
123-
return res;
124-
} catch (err) {
125-
await pptrPool.release(browser);
126-
throw err;
127-
}
128-
};
118+
): Promise<T> => pptrPool.use(callback);
129119

130120
export default function app(): FastifyInstance {
131121
const isProd = process.env.NODE_ENV === 'production';

0 commit comments

Comments
 (0)