Skip to content

Commit

Permalink
tweak: try alleviate oom killed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nomagick committed Sep 8, 2024
1 parent e324c46 commit c5abdf8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions backend/functions/src/cloud-functions/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ export class CrawlerHost extends RPCHost {
})
@CloudHTTPv2({
runtime: {
memory: '8GiB',
memory: '4GiB',
cpu: 4,
timeoutSeconds: 300,
concurrency: 22,
maxInstances: 455,
concurrency: 8,
maxInstances: 1250,
minInstances: 1,
},
tags: ['Crawler'],
Expand Down
10 changes: 8 additions & 2 deletions backend/functions/src/services/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import puppeteer from 'puppeteer-extra';

import puppeteerBlockResources from 'puppeteer-extra-plugin-block-resources';
import puppeteerPageProxy from 'puppeteer-extra-plugin-page-proxy';
import { SecurityCompromiseError, ServiceCrashedError } from '../shared/lib/errors';
import { SecurityCompromiseError, ServiceCrashedError, ServiceNodeResourceDrainError } from '../shared/lib/errors';
import { TimeoutError } from 'puppeteer';
import _ from 'lodash';
const tldExtract = require('tld-extract');
Expand Down Expand Up @@ -285,7 +285,13 @@ export class PuppeteerControl extends AsyncService {
await this.serviceReady();
const dedicatedContext = await this.browser.createBrowserContext();
const sn = this._sn++;
const page = await dedicatedContext.newPage();
let page
try {
page = await dedicatedContext.newPage();
} catch (err: any) {
this.logger.warn(`Failed to create page ${sn}`, { err: marshalErrorLike(err) });
throw new ServiceNodeResourceDrainError(`This specific worker node failed to open a new page, try again.`);
}
const preparations = [];

// preparations.push(page.setUserAgent(`Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)`));
Expand Down
2 changes: 1 addition & 1 deletion thinapps-shared

0 comments on commit c5abdf8

Please sign in to comment.