Skip to content

Commit

Permalink
fix(scraper): calling method on promise
Browse files Browse the repository at this point in the history
  • Loading branch information
mytlogos committed Sep 5, 2022
1 parent 222af51 commit 9c436a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const logger = winston.createLogger({
formatLogFmt(),
// use logfmt here too
format.printf((info) => {
return `${info.timestamp + ""} ${info.level}: ${info.message}`;
return `${info.timestamp + ""} ${info.level}: ${info.message + ""}`;
}),
),
}),
Expand Down
10 changes: 6 additions & 4 deletions packages/scraper/src/externals/request/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ function transformAxiosResponse(response: AxiosResponse): Response {
const pages = new Cache<string, Promise<Page>>({ stdTTL: 60 * 10, useClones: false, size: 20 });
const pageUsed = new Set<string>();

pages.on("expired", (_key, value: Page) => {
if (!value.isClosed()) {
value.close();
}
pages.on("expired", (_key, value: Promise<Page>) => {
value.then((page) => {
if (!page.isClosed()) {
page.close();
}
});
});

// Modified from https://www.bannerbear.com/blog/ways-to-speed-up-puppeteer-screenshots/
Expand Down

0 comments on commit 9c436a0

Please sign in to comment.