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 puppeteerPageProxy from 'puppeteer-extra-plugin-page-proxy';
|
||||||
import { SecurityCompromiseError, ServiceCrashedError } from '../shared/lib/errors';
|
import { SecurityCompromiseError, ServiceCrashedError } from '../shared/lib/errors';
|
||||||
import { TimeoutError } from 'puppeteer';
|
import { TimeoutError } from 'puppeteer';
|
||||||
|
import { AsyncContext } from '../shared';
|
||||||
const tldExtract = require('tld-extract');
|
const tldExtract = require('tld-extract');
|
||||||
|
|
||||||
const READABILITY_JS = fs.readFileSync(require.resolve('@mozilla/readability/Readability.js'), 'utf-8');
|
const READABILITY_JS = fs.readFileSync(require.resolve('@mozilla/readability/Readability.js'), 'utf-8');
|
||||||
|
@ -214,6 +215,7 @@ export class PuppeteerControl extends AsyncService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected globalLogger: Logger,
|
protected globalLogger: Logger,
|
||||||
|
protected threadLocal: AsyncContext,
|
||||||
) {
|
) {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
this.setMaxListeners(2 * Math.floor(os.totalmem() / (256 * 1024 * 1024)) + 1); 148 - 95;
|
this.setMaxListeners(2 * Math.floor(os.totalmem() / (256 * 1024 * 1024)) + 1); 148 - 95;
|
||||||
|
@ -494,9 +496,11 @@ document.addEventListener('load', handlePageLoad);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (s?.elemCount && s.elemCount > 20_000) {
|
if (s?.elemCount && s.elemCount > 20_000) {
|
||||||
|
if (!this.threadLocal.get('uid')) {
|
||||||
page.emit('abuse', { url, page, sn, reason: `DoS attack suspected: too many DOM elements` });
|
page.emit('abuse', { url, page, sn, reason: `DoS attack suspected: too many DOM elements` });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
snapshot = s;
|
snapshot = s;
|
||||||
nextSnapshotDeferred.resolve(s);
|
nextSnapshotDeferred.resolve(s);
|
||||||
nextSnapshotDeferred = Defer();
|
nextSnapshotDeferred = Defer();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user