sitespeed.io 34.2.0 → 34.2.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG - sitespeed.io (we use [semantic versioning](https://semver.org))
2
2
 
3
+ ## 34.2.1 - 2024-06-17
4
+ ### Changelog
5
+ * API: safer parsing if something fail to get better error messages [#4188](https://github.com/sitespeedio/sitespeed.io/pull/4188).
6
+
3
7
  ## 34.2.0 - 2024-06-14
4
8
 
5
9
  ### Added
package/lib/api/send.js CHANGED
@@ -24,13 +24,21 @@ export async function addTest(hostname, options) {
24
24
  let data = [];
25
25
  res.on('data', chunk => data.push(chunk));
26
26
  res.on('end', () => {
27
- return res.statusCode === 200
28
- ? resolve(Buffer.concat(data).toString('utf8'))
29
- : reject(JSON.parse(Buffer.concat(data).toString('utf8')));
27
+ if (res.statusCode === 200) {
28
+ return resolve(Buffer.concat(data).toString('utf8'));
29
+ } else {
30
+ try {
31
+ return reject(JSON.parse(Buffer.concat(data).toString('utf8')));
32
+ } catch {
33
+ return reject({
34
+ message:
35
+ 'Could parse result:' + Buffer.concat(data).toString('utf8')
36
+ });
37
+ }
38
+ }
30
39
  });
31
40
  });
32
41
  request.on('error', error => {
33
- console.log('onERror');
34
42
  reject({ message: error.toString() });
35
43
  });
36
44
  request.write(JSON.stringify(postData));
@@ -69,9 +77,18 @@ export async function get(testId, hostname, options) {
69
77
  });
70
78
 
71
79
  res.on('end', () => {
72
- return res.statusCode === 200
73
- ? resolve(JSON.parse(Buffer.concat(data).toString('utf8')))
74
- : reject(JSON.parse(Buffer.concat(data).toString('utf8')));
80
+ if (res.statusCode === 200) {
81
+ return resolve(JSON.parse(Buffer.concat(data).toString('utf8')));
82
+ } else {
83
+ try {
84
+ return reject(JSON.parse(Buffer.concat(data).toString('utf8')));
85
+ } catch {
86
+ return reject({
87
+ message:
88
+ 'Could parse result:' + Buffer.concat(data).toString('utf8')
89
+ });
90
+ }
91
+ }
75
92
  });
76
93
  })
77
94
  .on('error', () => {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "sitespeed.io",
3
- "version": "34.2.0",
3
+ "version": "34.2.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "sitespeed.io",
9
- "version": "34.2.0",
9
+ "version": "34.2.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-s3": "3.564.0",
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "sitespeed.io": "./bin/sitespeed.js",
6
6
  "sitespeed.io-wpr": "./bin/browsertimeWebPageReplay.js"
7
7
  },
8
- "version": "34.2.0",
8
+ "version": "34.2.1",
9
9
  "description": "sitespeed.io is an open-source tool for comprehensive web performance analysis, enabling you to test, monitor, and optimize your website’s speed using real browsers in various environments.",
10
10
  "keywords": [
11
11
  "performance",