Socket
Socket
Sign inDemoInstall

@percy/core

Package Overview
Dependencies
Maintainers
6
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@percy/core - npm Package Compare versions

Comparing version 1.26.3-beta.1 to 1.26.3-beta.2

63

dist/network.js

@@ -8,2 +8,3 @@ import mime from 'mime-types';

const ALLOWED_RESOURCES = ['Document', 'Stylesheet', 'Image', 'Media', 'Font', 'Other'];
const ABORTED_MESSAGE = 'Request was aborted by browser';

@@ -19,2 +20,3 @@ // The Interceptor class creates common handlers for dealing with intercepting asset requests

#authentications = new Set();
#aborted = new Set();
constructor(page, options) {

@@ -82,2 +84,19 @@ this.page = page;

// Validates that requestId is still valid as sometimes request gets cancelled and we have already executed
// _forgetRequest for the same, but we still attempt to make a call for it and it fails
// with Protocol error (Fetch.failRequest): Invalid InterceptionId.
async send(session, method, params) {
/* istanbul ignore else: currently all send have requestId */
if (params.requestId) {
/* istanbul ignore if: race condition, very hard to mock this */
if (this.isAborted(params.requestId)) {
throw new Error(ABORTED_MESSAGE);
}
}
return await session.send(method, params);
}
isAborted(requestId) {
return this.#aborted.has(requestId);
}
// Throw a better network timeout error

@@ -122,3 +141,3 @@ _throwTimeoutError(msg, filter = () => true) {

}
await session.send('Fetch.continueWithAuth', {
await this.send(session, 'Fetch.continueWithAuth', {
requestId: event.requestId,

@@ -229,3 +248,3 @@ authChallengeResponse: {

request.response.buffer = async () => {
let result = await session.send('Network.getResponseBody', {
let result = await this.send(session, 'Network.getResponseBody', {
requestId

@@ -261,4 +280,14 @@ });

// do not log generic messages since the real error was likely logged elsewhere
if (event.errorText !== 'net::ERR_FAILED') {
// If request was aborted, keep track of it as we need to cancel any in process callbacks for
// such a request to avoid Invalid InterceptionId errors
// Note: 404s also show up under ERR_ABORTED and not ERR_FAILED
if (event.errorText === 'net::ERR_ABORTED') {
let message = `Request aborted for ${request.url}: ${event.errorText}`;
this.log.debug(message, {
...this.meta,
url: request.url
});
this.#aborted.add(request.requestId);
} else if (event.errorText !== 'net::ERR_FAILED') {
// do not log generic messages since the real error was likely logged elsewhere
let message = `Request failed for ${request.url}: ${event.errorText}`;

@@ -298,2 +327,3 @@ this.log.debug(message, {

};
let send = (method, params) => network.send(session, method, params);
try {

@@ -304,3 +334,3 @@ let resource = network.intercept.getResource(url);

log.debug('- Skipping disallowed hostname', meta);
await session.send('Fetch.failRequest', {
await send('Fetch.failRequest', {
requestId: request.interceptId,

@@ -311,3 +341,3 @@ errorReason: 'Aborted'

log.debug(resource.root ? '- Serving root resource' : '- Resource cache hit', meta);
await session.send('Fetch.fulfillRequest', {
await send('Fetch.fulfillRequest', {
requestId: request.interceptId,

@@ -322,3 +352,3 @@ responseCode: resource.status || 200,

} else {
await session.send('Fetch.continueRequest', {
await send('Fetch.continueRequest', {
requestId: request.interceptId

@@ -330,2 +360,19 @@ });

if (session.closing && error.message.includes('close')) return;
// if failure is due to an already aborted request, ignore it
// due to race condition we might get aborted event later and see a `Invalid InterceptionId`
// error before, in which case we should wait for a tick and check again
// Note: its not a necessity that we would get aborted callback in a tick, its just that if we
// already have it then we can safely ignore this error
// Its very hard to test it as this function should be called and request should get cancelled before
if (error.message === ABORTED_MESSAGE || error.message.includes('Invalid InterceptionId')) {
// defer this to the end of queue to make sure that any incoming aborted messages were
// handled and network.#aborted is updated
await new Promise((res, _) => process.nextTick(res));
/* istanbul ignore else: too hard to create race where abortion event is delayed */
if (network.isAborted(request.requestId)) {
log.debug(`Ignoring further steps for ${url} as request was aborted by the browser.`);
return;
}
}
log.debug(`Encountered an error handling request: ${url}`, meta);

@@ -335,3 +382,3 @@ log.debug(error);

/* istanbul ignore next: catch race condition */
await session.send('Fetch.failRequest', {
await send('Fetch.failRequest', {
requestId: request.interceptId,

@@ -338,0 +385,0 @@ errorReason: 'Failed'

2

dist/snapshot.js

@@ -81,3 +81,3 @@ import logger from '@percy/logger';

// reduce snapshots with overrides
// reduce snapshots with options
return snapshots.reduce((acc, snapshot) => {

@@ -84,0 +84,0 @@ var _snapshot;

{
"name": "@percy/core",
"version": "1.26.3-beta.1",
"version": "1.26.3-beta.2",
"license": "MIT",

@@ -46,6 +46,6 @@ "repository": {

"dependencies": {
"@percy/client": "1.26.3-beta.1",
"@percy/config": "1.26.3-beta.1",
"@percy/dom": "1.26.3-beta.1",
"@percy/logger": "1.26.3-beta.1",
"@percy/client": "1.26.3-beta.2",
"@percy/config": "1.26.3-beta.2",
"@percy/dom": "1.26.3-beta.2",
"@percy/logger": "1.26.3-beta.2",
"content-disposition": "^0.5.4",

@@ -61,3 +61,3 @@ "cross-spawn": "^7.0.3",

},
"gitHead": "6571d4ad016bc8b3b32d49bf8a7da1393c1a5eba"
"gitHead": "5e402f5ff469cc521506fef6a347e04a1a2e1434"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc