unprint 0.19.9 → 0.19.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/app.js +15 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unprint",
3
- "version": "0.19.9",
3
+ "version": "0.19.11",
4
4
  "description": "Simplify common web scraping tasks while staying in control of the data.",
5
5
  "main": "src/app.js",
6
6
  "scripts": {
package/src/app.js CHANGED
@@ -16,8 +16,8 @@ const srcset = require('srcset');
16
16
  const settings = {
17
17
  throwErrors: false,
18
18
  logErrors: true,
19
- requestTimeout: 30000,
20
19
  userAgent: 'unprint',
20
+ timeout: 60_000,
21
21
  remote: {
22
22
  enable: false,
23
23
  address: 'ws://127.0.0.1:3333/browser',
@@ -1280,10 +1280,18 @@ async function getBrowserInstance(scope, options, useProxy = false, useRemote =
1280
1280
  clients.set(scopeKey, client);
1281
1281
  }
1282
1282
 
1283
- const { browser, context } = await launchers;
1283
+ try {
1284
+ const { browser, context } = await launchers;
1285
+
1286
+ context.setDefaultNavigationTimeout(options.timeout);
1284
1287
 
1285
- client.browser = browser;
1286
- client.context = context;
1288
+ client.browser = browser;
1289
+ client.context = context;
1290
+ } catch (error) {
1291
+ clients.delete(scopeKey);
1292
+
1293
+ return error;
1294
+ }
1287
1295
 
1288
1296
  return client;
1289
1297
  }
@@ -1379,7 +1387,7 @@ function useRemoteRequest(options) {
1379
1387
 
1380
1388
  async function browserRequest(url, customOptions = {}) {
1381
1389
  const options = merge.all([{
1382
- timeout: 10000,
1390
+ timeout: 60000,
1383
1391
  extract: true,
1384
1392
  client: 'main',
1385
1393
  limiter: 'browser',
@@ -1405,7 +1413,7 @@ async function browserRequest(url, customOptions = {}) {
1405
1413
  events.emit('requestInit', feedbackBase);
1406
1414
 
1407
1415
  return limiter.schedule(async () => {
1408
- const client = await getBrowserInstance(options.client, options, useProxy, useRemote).catch((error) => error);
1416
+ const client = await getBrowserInstance(options.client, options, useProxy, useRemote);
1409
1417
 
1410
1418
  if (client instanceof Error) {
1411
1419
  return {
@@ -1572,7 +1580,7 @@ async function request(url, customOptions = {}, redirects = 0) {
1572
1580
  method: 'get',
1573
1581
  body: null,
1574
1582
  interface: 'fetch', // fetch or request
1575
- timeout: 10000,
1583
+ timeout: 60000,
1576
1584
  extract: true,
1577
1585
  followRedirects: true,
1578
1586
  maxRedirects: 3,