@percy/client 1.28.8 → 1.28.9-beta.0

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/dist/client.js CHANGED
@@ -3,7 +3,7 @@ import PercyEnv from '@percy/env';
3
3
  import { git } from '@percy/env/utils';
4
4
  import logger from '@percy/logger';
5
5
  import Pako from 'pako';
6
- import { pool, request, formatBytes, sha256hash, base64encode, getPackageJSON, waitForTimeout, validateTiles, tagsList } from './utils.js';
6
+ import { pool, request, formatBytes, sha256hash, base64encode, getPackageJSON, waitForTimeout, validateTiles, formatLogErrors, tagsList } from './utils.js';
7
7
 
8
8
  // Default client API URL can be set with an env var for API development
9
9
  const {
@@ -543,8 +543,12 @@ export class PercyClient {
543
543
  retries -= 1;
544
544
  } while (retries > 0 && !success);
545
545
  if (!success) {
546
- this.log.error('Uploading comparison tile failed');
547
- return false;
546
+ let errMsg = 'Uploading comparison tile failed';
547
+
548
+ // Detecting error and logging fix for the same
549
+ // We are throwing this error as the comparison will be failed
550
+ // even if 1 tile gets failed
551
+ throw new Error(errMsg);
548
552
  }
549
553
  return true;
550
554
  }
@@ -609,6 +613,13 @@ export class PercyClient {
609
613
  data: body
610
614
  });
611
615
  }
616
+ async getErrorAnalysis(errors) {
617
+ const errorLogs = formatLogErrors(errors);
618
+ this.log.debug('Sending error logs for analysis');
619
+ return this.post('suggestions/from_logs', {
620
+ data: errorLogs
621
+ });
622
+ }
612
623
  mayBeLogUploadSize(contentSize) {
613
624
  if (contentSize >= 25 * 1024 * 1024) {
614
625
  this.log.error('Uploading resource above 25MB might fail the build...');
package/dist/proxy.js CHANGED
@@ -155,8 +155,16 @@ export class ProxyHttpsAgent extends https.Agent {
155
155
  // start the proxy connection and setup listeners
156
156
  let socket = proxy.connect();
157
157
  let handleError = err => {
158
+ var _err$message, _err$message2;
158
159
  socket.destroy(err);
159
160
  logger('client:proxy').error(`Proxying request failed: ${err}`);
161
+
162
+ // We don't get statusCode here, relying on checking error message only
163
+ if (!!err.message && ((_err$message = err.message) !== null && _err$message !== void 0 && _err$message.includes('ECONNREFUSED') || (_err$message2 = err.message) !== null && _err$message2 !== void 0 && _err$message2.includes('EHOSTUNREACH'))) {
164
+ logger('client:proxy').warn('If needed, Please verify if your proxy credentials are correct');
165
+ logger('client:proxy').warn('Please check if your proxy is set correctly and reachable');
166
+ }
167
+ logger('client:proxy').warn('Please check network connection, proxy and ensure that following domains are whitelisted: github.com, percy.io, storage.googleapis.com. In case you are an enterprise customer make sure to whitelist "percy-enterprise.browserstack.com" as well.');
160
168
  callback(err);
161
169
  };
162
170
  let handleClose = () => handleError(new Error('Connection closed while sending request to upstream proxy'));
package/dist/utils.js CHANGED
@@ -233,6 +233,26 @@ export function validateTiles(tiles) {
233
233
  }
234
234
  return true;
235
235
  }
236
+ export function formatLogErrors(errorLogs) {
237
+ let errors = [];
238
+ if (typeof errorLogs === 'string') {
239
+ errors.push({
240
+ message: errorLogs
241
+ });
242
+ } else if (Array.isArray(errorLogs)) {
243
+ errors = errorLogs;
244
+ } else {
245
+ errors.push({
246
+ message: errorLogs
247
+ });
248
+ errors.push({
249
+ message: (errorLogs === null || errorLogs === void 0 ? void 0 : errorLogs.message) || ''
250
+ });
251
+ }
252
+ return {
253
+ logs: errors
254
+ };
255
+ }
236
256
 
237
257
  // convert tags comma-separated-names to array of objects for POST request
238
258
  export function tagsList(tags) {
@@ -246,4 +266,4 @@ export function tagsList(tags) {
246
266
  }
247
267
  return tagsArr;
248
268
  }
249
- export { hostnameMatches, ProxyHttpAgent, ProxyHttpsAgent, proxyAgentFor } from './proxy.js';
269
+ export { hostnameMatches, getProxy, ProxyHttpAgent, ProxyHttpsAgent, proxyAgentFor } from './proxy.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/client",
3
- "version": "1.28.8",
3
+ "version": "1.28.9-beta.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "latest"
12
+ "tag": "beta"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -32,9 +32,9 @@
32
32
  "test:coverage": "yarn test --coverage"
33
33
  },
34
34
  "dependencies": {
35
- "@percy/env": "1.28.8",
36
- "@percy/logger": "1.28.8",
35
+ "@percy/env": "1.28.9-beta.0",
36
+ "@percy/logger": "1.28.9-beta.0",
37
37
  "pako": "^2.1.0"
38
38
  },
39
- "gitHead": "1b93761a01b608afadf8d4efccacc11f925396bd"
39
+ "gitHead": "a1114f1e18518012f48756c9558a8e7895d2b3a9"
40
40
  }