Socket
Socket
Sign inDemoInstall

@web/test-runner-core

Package Overview
Dependencies
Maintainers
7
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/test-runner-core - npm Package Compare versions

Comparing version 0.10.1 to 0.10.2

6

CHANGELOG.md
# @web/test-runner-core
## 0.10.2
### Patch Changes
- 66638204: deduplicate parallel source map requests
## 0.10.1

@@ -4,0 +10,0 @@

44

dist/server/plugins/api/createSourceMapFunction.js

@@ -29,9 +29,11 @@ "use strict";

// from a server plugin which no longer exists
if (!body)
return null;
return (
if (!body) {
return;
}
const sourceMap =
// inline source map
convert_source_map_1.default.fromSource(body) ||
// external source map
convert_source_map_1.default.fromMapFileSource(body, path_1.dirname(filePath)));
convert_source_map_1.default.fromMapFileSource(body, path_1.dirname(filePath));
return sourceMap !== null && sourceMap !== void 0 ? sourceMap : undefined;
}

@@ -58,18 +60,36 @@ function resolveRelativeTo(relativeTo, path) {

const cacheKey = `${filePath}${userAgent}`;
const cached = cachedSourceMaps.get(cacheKey);
if (cached === null) {
// null means we know there isn't a source map for this file
return null;
let cached = cachedSourceMaps.get(cacheKey);
if (cached) {
if (cached.loadingPromise) {
// a request for this source map is already being done in parallel, wait for it to finish
await cached.loadingPromise;
}
if (!cached.sourceMap) {
// we know there is no source map for this file
return null;
}
}
cached = {};
cachedSourceMaps.set(cacheKey, cached);
// get the raw source map, from cache or new
let sourceMap;
if (cached === null || cached === void 0 ? void 0 : cached.sourceMap) {
if (cached.sourceMap) {
sourceMap = cached === null || cached === void 0 ? void 0 : cached.sourceMap;
}
else {
sourceMap = await fetchSourceMap(protocol, host, port, browserUrl, filePath, userAgent);
cachedSourceMaps.set(cacheKey, sourceMap ? { sourceMap: sourceMap } : null);
if (!sourceMap) {
// fetch source map, maintain a loading boolean for parallel calls to wait before resolving
let resolveLoading;
const loadingPromise = new Promise(resolve => {
resolveLoading = resolve;
});
cached.loadingPromise = loadingPromise;
const result = await fetchSourceMap(protocol, host, port, browserUrl, filePath, userAgent);
cached.sourceMap = result;
resolveLoading();
if (!result) {
return null;
}
else {
sourceMap = result;
}
}

@@ -76,0 +96,0 @@ // if there is no line and column we're looking for just the associated file, for example

{
"name": "@web/test-runner-core",
"version": "0.10.1",
"version": "0.10.2",
"publishConfig": {

@@ -60,3 +60,3 @@ "access": "public"

"debounce": "^1.2.0",
"dependency-graph": "^0.9.0",
"dependency-graph": "^0.10.0",
"globby": "^11.0.1",

@@ -63,0 +63,0 @@ "ip": "^1.1.5",

@@ -15,4 +15,5 @@ import { dirname, join } from 'path';

interface CachedSourceMap {
sourceMap: SourceMapConverter;
sourceMap?: SourceMapConverter;
consumer?: SourceMapConsumer;
loadingPromise?: Promise<void>;
}

@@ -45,10 +46,12 @@

// from a server plugin which no longer exists
if (!body) return null;
if (!body) {
return;
}
return (
const sourceMap =
// inline source map
convertSourceMap.fromSource(body) ||
// external source map
convertSourceMap.fromMapFileSource(body, dirname(filePath))
);
convertSourceMap.fromMapFileSource(body, dirname(filePath));
return sourceMap ?? undefined;
}

@@ -81,17 +84,37 @@

const cacheKey = `${filePath}${userAgent}`;
const cached = cachedSourceMaps.get(cacheKey);
if (cached === null) {
// null means we know there isn't a source map for this file
return null;
let cached = cachedSourceMaps.get(cacheKey);
if (cached) {
if (cached.loadingPromise) {
// a request for this source map is already being done in parallel, wait for it to finish
await cached.loadingPromise;
}
if (!cached.sourceMap) {
// we know there is no source map for this file
return null;
}
}
cached = {};
cachedSourceMaps.set(cacheKey, cached);
// get the raw source map, from cache or new
let sourceMap: SourceMapConverter | null;
if (cached?.sourceMap) {
let sourceMap: SourceMapConverter;
if (cached.sourceMap) {
sourceMap = cached?.sourceMap;
} else {
sourceMap = await fetchSourceMap(protocol, host, port, browserUrl, filePath, userAgent);
cachedSourceMaps.set(cacheKey, sourceMap ? { sourceMap: sourceMap } : null);
if (!sourceMap) {
// fetch source map, maintain a loading boolean for parallel calls to wait before resolving
let resolveLoading: () => void;
const loadingPromise = new Promise<void>(resolve => {
resolveLoading = resolve;
});
cached.loadingPromise = loadingPromise;
const result = await fetchSourceMap(protocol, host, port, browserUrl, filePath, userAgent);
cached.sourceMap = result;
resolveLoading!();
if (!result) {
return null;
} else {
sourceMap = result;
}

@@ -98,0 +121,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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