@percy/core 1.31.6-beta.8 → 1.31.7-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/browser.js +26 -0
- package/dist/config.js +30 -1
- package/dist/discovery.js +12 -1
- package/dist/utils.js +1 -1
- package/package.json +8 -8
package/dist/browser.js
CHANGED
|
@@ -123,6 +123,27 @@ export class Browser extends EventEmitter {
|
|
|
123
123
|
var _this$ws;
|
|
124
124
|
return ((_this$ws = this.ws) === null || _this$ws === void 0 ? void 0 : _this$ws.readyState) === WebSocket.OPEN;
|
|
125
125
|
}
|
|
126
|
+
async restart() {
|
|
127
|
+
this.log.info('Restarting browser after disconnection');
|
|
128
|
+
|
|
129
|
+
// Force close the existing browser instance
|
|
130
|
+
/* istanbul ignore next: Hard to mock */
|
|
131
|
+
if (this.readyState !== null) {
|
|
132
|
+
await this.close(true).catch(err => {
|
|
133
|
+
this.log.debug('Error during force close:', err);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Reset state for fresh launch
|
|
138
|
+
this.readyState = null;
|
|
139
|
+
this._closed = null;
|
|
140
|
+
this.#callbacks.clear();
|
|
141
|
+
this.sessions.clear();
|
|
142
|
+
|
|
143
|
+
// Launch a new browser instance
|
|
144
|
+
await this.launch();
|
|
145
|
+
this.log.info('Browser restarted successfully');
|
|
146
|
+
}
|
|
126
147
|
async close(force = false) {
|
|
127
148
|
var _this$percy$config$di, _this$process, _this$ws2;
|
|
128
149
|
// Check for the new closeBrowser option
|
|
@@ -194,6 +215,11 @@ export class Browser extends EventEmitter {
|
|
|
194
215
|
return this._closed;
|
|
195
216
|
}
|
|
196
217
|
async page(options = {}) {
|
|
218
|
+
// Check if browser is connected, restart if needed
|
|
219
|
+
if (!this.isConnected()) {
|
|
220
|
+
this.log.warn('Browser disconnected, attempting restart');
|
|
221
|
+
await this.restart();
|
|
222
|
+
}
|
|
197
223
|
let {
|
|
198
224
|
targetId
|
|
199
225
|
} = await this.send('Target.createTarget', {
|
package/dist/config.js
CHANGED
|
@@ -482,7 +482,7 @@ export const configSchema = {
|
|
|
482
482
|
},
|
|
483
483
|
retry: {
|
|
484
484
|
type: 'boolean',
|
|
485
|
-
default:
|
|
485
|
+
default: true
|
|
486
486
|
},
|
|
487
487
|
launchOptions: {
|
|
488
488
|
type: 'object',
|
|
@@ -1176,6 +1176,35 @@ export const comparisonSchema = {
|
|
|
1176
1176
|
properties: {
|
|
1177
1177
|
considerElementsData: regionsSchema
|
|
1178
1178
|
}
|
|
1179
|
+
},
|
|
1180
|
+
elementSelectorsData: {
|
|
1181
|
+
type: 'object',
|
|
1182
|
+
additionalProperties: {
|
|
1183
|
+
type: 'object',
|
|
1184
|
+
properties: {
|
|
1185
|
+
success: {
|
|
1186
|
+
type: 'boolean'
|
|
1187
|
+
},
|
|
1188
|
+
top: {
|
|
1189
|
+
type: ['number', 'null']
|
|
1190
|
+
},
|
|
1191
|
+
left: {
|
|
1192
|
+
type: ['number', 'null']
|
|
1193
|
+
},
|
|
1194
|
+
bottom: {
|
|
1195
|
+
type: ['number', 'null']
|
|
1196
|
+
},
|
|
1197
|
+
right: {
|
|
1198
|
+
type: ['number', 'null']
|
|
1199
|
+
},
|
|
1200
|
+
message: {
|
|
1201
|
+
type: ['string', 'null']
|
|
1202
|
+
},
|
|
1203
|
+
stacktrace: {
|
|
1204
|
+
type: ['string', 'null']
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1179
1208
|
}
|
|
1180
1209
|
}
|
|
1181
1210
|
};
|
package/dist/discovery.js
CHANGED
|
@@ -541,8 +541,19 @@ export function createDiscoveryQueue(percy) {
|
|
|
541
541
|
}
|
|
542
542
|
}, {
|
|
543
543
|
count: snapshot.discovery.retry ? 3 : 1,
|
|
544
|
-
onRetry:
|
|
544
|
+
onRetry: async error => {
|
|
545
|
+
var _error$message, _error$message2, _error$message3, _error$message4;
|
|
545
546
|
percy.log.info(`Retrying snapshot: ${snapshotLogName(snapshot.name, snapshot.meta)}`, snapshot.meta);
|
|
547
|
+
// If browser disconnected or crashed, restart it before retrying
|
|
548
|
+
if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes('Browser not connected') || error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes('Browser closed') || error !== null && error !== void 0 && (_error$message3 = error.message) !== null && _error$message3 !== void 0 && _error$message3.includes('Session closed') || error !== null && error !== void 0 && (_error$message4 = error.message) !== null && _error$message4 !== void 0 && _error$message4.includes('Session crashed')) {
|
|
549
|
+
percy.log.warn('Detected browser disconnection, restarting browser before retry');
|
|
550
|
+
try {
|
|
551
|
+
await percy.browser.restart();
|
|
552
|
+
} catch (restartError) {
|
|
553
|
+
percy.log.error(`Failed to restart browser: ${restartError}`);
|
|
554
|
+
throw restartError;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
546
557
|
},
|
|
547
558
|
signal: snapshot._ctrl.signal,
|
|
548
559
|
throwOn: ['AbortError']
|
package/dist/utils.js
CHANGED
|
@@ -419,7 +419,7 @@ export async function withRetries(fn, {
|
|
|
419
419
|
// if this error should not be retried on, we want to skip errors
|
|
420
420
|
let throwError = throwOn === null || throwOn === void 0 ? void 0 : throwOn.includes(e.name);
|
|
421
421
|
if (!throwError && run < count) {
|
|
422
|
-
await (onRetry === null || onRetry === void 0 ? void 0 : onRetry());
|
|
422
|
+
await (onRetry === null || onRetry === void 0 ? void 0 : onRetry(e));
|
|
423
423
|
continue;
|
|
424
424
|
}
|
|
425
425
|
throw e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.7-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"test:types": "tsd"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@percy/client": "1.31.
|
|
47
|
-
"@percy/config": "1.31.
|
|
48
|
-
"@percy/dom": "1.31.
|
|
49
|
-
"@percy/logger": "1.31.
|
|
50
|
-
"@percy/monitoring": "1.31.
|
|
51
|
-
"@percy/webdriver-utils": "1.31.
|
|
46
|
+
"@percy/client": "1.31.7-beta.0",
|
|
47
|
+
"@percy/config": "1.31.7-beta.0",
|
|
48
|
+
"@percy/dom": "1.31.7-beta.0",
|
|
49
|
+
"@percy/logger": "1.31.7-beta.0",
|
|
50
|
+
"@percy/monitoring": "1.31.7-beta.0",
|
|
51
|
+
"@percy/webdriver-utils": "1.31.7-beta.0",
|
|
52
52
|
"content-disposition": "^0.5.4",
|
|
53
53
|
"cross-spawn": "^7.0.3",
|
|
54
54
|
"extract-zip": "^2.0.1",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"ws": "^8.17.1",
|
|
62
62
|
"yaml": "^2.4.1"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f2a30c44c75c67e915a8916aac7cea77fcbf26f3"
|
|
65
65
|
}
|