mirror of
https://github.com/intergalacticalvariable/reader.git
synced 2024-11-16 03:32:25 +08:00
fix
This commit is contained in:
parent
f4f189c8e6
commit
e658e8102c
|
@ -11,6 +11,7 @@ import puppeteerBlockResources from 'puppeteer-extra-plugin-block-resources';
|
|||
import puppeteerPageProxy from 'puppeteer-extra-plugin-page-proxy';
|
||||
import { SecurityCompromiseError, ServiceCrashedError } from '../shared/lib/errors';
|
||||
import { TimeoutError } from 'puppeteer';
|
||||
import { AsyncContext } from '../shared';
|
||||
const tldExtract = require('tld-extract');
|
||||
|
||||
const READABILITY_JS = fs.readFileSync(require.resolve('@mozilla/readability/Readability.js'), 'utf-8');
|
||||
|
@ -214,6 +215,7 @@ export class PuppeteerControl extends AsyncService {
|
|||
|
||||
constructor(
|
||||
protected globalLogger: Logger,
|
||||
protected threadLocal: AsyncContext,
|
||||
) {
|
||||
super(...arguments);
|
||||
this.setMaxListeners(2 * Math.floor(os.totalmem() / (256 * 1024 * 1024)) + 1); 148 - 95;
|
||||
|
@ -494,8 +496,10 @@ document.addEventListener('load', handlePageLoad);
|
|||
return;
|
||||
}
|
||||
if (s?.elemCount && s.elemCount > 20_000) {
|
||||
page.emit('abuse', { url, page, sn, reason: `DoS attack suspected: too many DOM elements` });
|
||||
return;
|
||||
if (!this.threadLocal.get('uid')) {
|
||||
page.emit('abuse', { url, page, sn, reason: `DoS attack suspected: too many DOM elements` });
|
||||
return;
|
||||
}
|
||||
}
|
||||
snapshot = s;
|
||||
nextSnapshotDeferred.resolve(s);
|
||||
|
|
Loading…
Reference in New Issue
Block a user