grover 1.1.6 → 1.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1de71127ef3e7173bce45deeec104ec9c876dea335ad73dfc80016da64c64f7
4
- data.tar.gz: 50dce7d9aa7ef01e12144f303868667e4d6587d0dc9a7be337c34d9679e483c0
3
+ metadata.gz: e791010e46d99d4347edc987fc2a7b90b08d038a1449cf927b57b828e58f1d59
4
+ data.tar.gz: 62837cb867ec1728c000c91b33352f01a1c4beb5b0823647dff74946d09c0cbd
5
5
  SHA512:
6
- metadata.gz: '084b8e564818202eead00cb7faef9c181e5bd394e41113fb4b87233fa9fe44ed434318240034a375f20799af909a647fc8dd816f9d74aa79ad101efaa329387f'
7
- data.tar.gz: 5f03611f7f945dac5b75424bc879f90e639f4a97430759028f3cf36727c4c490813dc15fc68271767b1996716278484eae0d7383a42741fbd24f2d572124d4e2
6
+ metadata.gz: 1471dda6f9817f921ae1f7ef88cbdf0ffab143448b1057ef1e3f71f5d91a9fce95b77fbece05f10c0823b51fbc181a4138ae5a6c6db437074c2d95143e90fa4d
7
+ data.tar.gz: fad1c63de120fb414aa23ffcf0b2adec6e419550ec2add1c5008ce3e1d855343934bbae4de1e9a14f8c74e974699ad7a74aad2a22bc2d6ef7ba1cd8850a73b36
@@ -1,13 +1,25 @@
1
1
  // Setup imports
2
2
  try {
3
3
  const Module = require('module');
4
- // resolve puppeteer from the CWD instead of where this script is located
5
- var puppeteer = require(require.resolve('puppeteer', { paths: Module._nodeModulePaths(process.cwd()) }));
4
+
5
+ try {
6
+ // resolve puppeteer from the CWD instead of where this script is located
7
+ var puppeteer = require(require.resolve('puppeteer', { paths: Module._nodeModulePaths(process.cwd()) }));
8
+ } catch (puppeteerError) {
9
+ try {
10
+ // try resolve `puppeteer-core` library instead
11
+ var puppeteer = require(require.resolve('puppeteer-core', { paths: Module._nodeModulePaths(process.cwd()) }));
12
+ } catch (coreError) {
13
+ // raise the original puppeteer load issue so we don't send people don't the wrong rabbit hole by default.
14
+ throw puppeteerError;
15
+ }
16
+ }
6
17
  } catch (e) {
7
18
  process.stdout.write(JSON.stringify(['err', e.toString()]));
8
19
  process.stdout.write("\n");
9
20
  process.exit(1);
10
21
  }
22
+
11
23
  process.stdout.write("[\"ok\"]\n");
12
24
 
13
25
  const fs = require('fs');
@@ -15,7 +27,7 @@ const os = require('os');
15
27
  const path = require('path');
16
28
 
17
29
  const _processPage = (async (convertAction, urlOrHtml, options) => {
18
- let browser, errors = [], tmpDir;
30
+ let browser, page, errors = [], tmpDir, wsConnection = false;
19
31
 
20
32
  try {
21
33
  // Configure puppeteer debugging options
@@ -25,8 +37,18 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
25
37
  const connectParams = {
26
38
  browserWSEndpoint: browserWsEndpoint,
27
39
  };
28
-
29
- browser = await puppeteer.connect(connectParams);
40
+ wsConnection = true;
41
+
42
+ try {
43
+ browser = await puppeteer.connect(connectParams);
44
+ } catch {
45
+ function WsConnectFailedError() {
46
+ this.name = "WsConnectFailedError";
47
+ this.message = `Failed to connect to browser WS endpoint: ${browserWsEndpoint}`;
48
+ }
49
+ WsConnectFailedError.prototype = Error.prototype;
50
+ throw new WsConnectFailedError();
51
+ }
30
52
  } else {
31
53
  tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'grover-'));
32
54
 
@@ -34,29 +56,29 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
34
56
  args: process.env.GROVER_NO_SANDBOX === 'true' ? ['--no-sandbox', '--disable-setuid-sandbox'] : [],
35
57
  userDataDir: tmpDir
36
58
  };
37
-
59
+
38
60
  if (typeof debug === 'object' && !!debug) {
39
61
  if (debug.headless !== undefined) { launchParams.headless = debug.headless; }
40
62
  if (debug.devtools !== undefined) { launchParams.devtools = debug.devtools; }
41
63
  }
42
-
64
+
43
65
  // Configure additional launch arguments
44
66
  const args = options.launchArgs; delete options.launchArgs;
45
67
  if (Array.isArray(args)) {
46
68
  launchParams.args = launchParams.args.concat(args);
47
69
  }
48
-
70
+
49
71
  // Set executable path if given
50
72
  const executablePath = options.executablePath; delete options.executablePath;
51
73
  if (executablePath) {
52
74
  launchParams.executablePath = executablePath;
53
75
  }
54
-
76
+
55
77
  // Launch the browser and create a page
56
78
  browser = await puppeteer.launch(launchParams);
57
79
  }
58
80
 
59
- const page = await browser.newPage();
81
+ page = await browser.newPage();
60
82
 
61
83
  // Basic auth
62
84
  const username = options.username; delete options.username
@@ -261,7 +283,12 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
261
283
  }
262
284
  } finally {
263
285
  if (browser) {
264
- await browser.close();
286
+ if (wsConnection) {
287
+ if (page) await page.close();
288
+ await browser.disconnect();
289
+ } else {
290
+ await browser.close();
291
+ }
265
292
  }
266
293
 
267
294
  try {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Grover
4
- VERSION = '1.1.6'
4
+ VERSION = '1.1.7'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grover
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bromwich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-15 00:00:00.000000000 Z
11
+ date: 2024-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: combine_pdf