mirror of
https://github.com/intergalacticalvariable/reader.git
synced 2024-11-16 11:42:32 +08:00
fix
This commit is contained in:
parent
77174f1511
commit
e17ef6dba0
|
@ -1,9 +1,14 @@
|
|||
const {join} = require('path');
|
||||
|
||||
let config = {};
|
||||
if (!process.env.FUNCTIONS_EMULATOR) {
|
||||
config = {
|
||||
// Changes the cache location for Puppeteer.
|
||||
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import("puppeteer").Configuration}
|
||||
*/
|
||||
module.exports = {
|
||||
// Changes the cache location for Puppeteer.
|
||||
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
|
||||
};
|
||||
module.exports = config;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"start": "npm run shell",
|
||||
"deploy": "firebase deploy --only functions",
|
||||
"logs": "firebase functions:log",
|
||||
"gcp-build": "node node_modules/puppeteer/install.js"
|
||||
"gcp-build": "node node_modules/puppeteer/install.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20"
|
||||
|
|
|
@ -30,3 +30,5 @@ Object.assign(exports, registry.exportGrouped({
|
|||
}));
|
||||
registry.title = 'url2text';
|
||||
registry.version = '0.1.0';
|
||||
|
||||
process.on('unhandledRejection', () => 'no big deal');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AsyncService, Defer, HashManager, marshalErrorLike } from 'civkit';
|
||||
import { AssertionFailureError, AsyncService, Defer, HashManager, marshalErrorLike } from 'civkit';
|
||||
import { container, singleton } from 'tsyringe';
|
||||
import puppeteer, { Browser } from 'puppeteer';
|
||||
import { Logger } from '../shared/services/logger';
|
||||
|
@ -72,7 +72,6 @@ export class PuppeteerControl extends AsyncService {
|
|||
}
|
||||
this.browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
||||
});
|
||||
this.browser.once('disconnected', () => {
|
||||
this.logger.warn(`Browser disconnected`);
|
||||
|
@ -212,20 +211,20 @@ function giveSnapshot() {
|
|||
});
|
||||
|
||||
return r;
|
||||
}).catch((err) => {
|
||||
this.logger.warn(`Failed to goto ${url}`, { err: marshalErrorLike(err) });
|
||||
return Promise.reject(new AssertionFailureError({
|
||||
message: `Failed to goto ${url}: ${err}`,
|
||||
cause: err,
|
||||
}));
|
||||
}).finally(() => {
|
||||
finalized = true;
|
||||
});
|
||||
|
||||
gotoPromise.catch((err) => {
|
||||
this.logger.warn(`Browsing of ${url} not fully done`, { err: marshalErrorLike(err) });
|
||||
}).finally(() => {
|
||||
finalized = true;
|
||||
});
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
await Promise.race([nextSnapshotDeferred.promise, gotoPromise]);
|
||||
if (finalized) {
|
||||
await gotoPromise;
|
||||
|
||||
yield { ...snapshot, screenshot };
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user