@flareapp/webpack 2.12.0 → 2.12.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/dist/index.cjs CHANGED
@@ -34,6 +34,29 @@ let webpack = require("webpack");
34
34
  webpack = __toESM(webpack);
35
35
 
36
36
  //#region ../flare-api/dist/index.mjs
37
+ async function settleWithConcurrency(items, concurrency, task) {
38
+ const results = Array.from({ length: items.length });
39
+ let nextIndex = 0;
40
+ async function worker() {
41
+ while (nextIndex < items.length) {
42
+ const index = nextIndex++;
43
+ try {
44
+ results[index] = {
45
+ status: "fulfilled",
46
+ value: await task(items[index])
47
+ };
48
+ } catch (reason) {
49
+ results[index] = {
50
+ status: "rejected",
51
+ reason
52
+ };
53
+ }
54
+ }
55
+ }
56
+ const workerCount = Math.min(concurrency, items.length);
57
+ await Promise.all(Array.from({ length: workerCount }, () => worker()));
58
+ return results;
59
+ }
37
60
  var FlareApiError = class extends Error {
38
61
  constructor(message) {
39
62
  super(message);
@@ -46,6 +69,7 @@ const RETRIABLE_STATUS_CODES = new Set([
46
69
  503,
47
70
  504
48
71
  ]);
72
+ const MAX_CONCURRENT_UPLOADS = 10;
49
73
  function describeNetworkError(error) {
50
74
  if (!(error instanceof Error)) return String(error);
51
75
  const cause = error.cause;
@@ -69,6 +93,9 @@ var FlareApi = class {
69
93
  sourcemap: base64GzipSourcemap
70
94
  });
71
95
  }
96
+ uploadSourcemaps(sourcemaps) {
97
+ return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
98
+ }
72
99
  async postWithRetry(data, maxRetries = 3) {
73
100
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
74
101
  try {
@@ -134,7 +161,7 @@ var FlareWebpackPlugin = class {
134
161
  return;
135
162
  }
136
163
  log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
137
- const results = await Promise.allSettled(sourcemaps.map(({ sourcemap }) => flare.uploadSourcemap(sourcemap)));
164
+ const results = await flare.uploadSourcemaps(sourcemaps.map(({ sourcemap }) => sourcemap));
138
165
  const failed = results.filter((r) => r.status === "rejected");
139
166
  if (failed.length > 0) for (const result of failed) compilation.warnings.push(new webpack.default.WebpackError(`@flareapp/webpack: Upload failed: ${result.reason}`));
140
167
  else log("Successfully uploaded all sourcemaps to Flare.");
package/dist/index.mjs CHANGED
@@ -5,6 +5,29 @@ import { deflateRawSync } from "node:zlib";
5
5
  import webpack from "webpack";
6
6
 
7
7
  //#region ../flare-api/dist/index.mjs
8
+ async function settleWithConcurrency(items, concurrency, task) {
9
+ const results = Array.from({ length: items.length });
10
+ let nextIndex = 0;
11
+ async function worker() {
12
+ while (nextIndex < items.length) {
13
+ const index = nextIndex++;
14
+ try {
15
+ results[index] = {
16
+ status: "fulfilled",
17
+ value: await task(items[index])
18
+ };
19
+ } catch (reason) {
20
+ results[index] = {
21
+ status: "rejected",
22
+ reason
23
+ };
24
+ }
25
+ }
26
+ }
27
+ const workerCount = Math.min(concurrency, items.length);
28
+ await Promise.all(Array.from({ length: workerCount }, () => worker()));
29
+ return results;
30
+ }
8
31
  var FlareApiError = class extends Error {
9
32
  constructor(message) {
10
33
  super(message);
@@ -17,6 +40,7 @@ const RETRIABLE_STATUS_CODES = new Set([
17
40
  503,
18
41
  504
19
42
  ]);
43
+ const MAX_CONCURRENT_UPLOADS = 10;
20
44
  function describeNetworkError(error) {
21
45
  if (!(error instanceof Error)) return String(error);
22
46
  const cause = error.cause;
@@ -40,6 +64,9 @@ var FlareApi = class {
40
64
  sourcemap: base64GzipSourcemap
41
65
  });
42
66
  }
67
+ uploadSourcemaps(sourcemaps) {
68
+ return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
69
+ }
43
70
  async postWithRetry(data, maxRetries = 3) {
44
71
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
45
72
  try {
@@ -105,7 +132,7 @@ var FlareWebpackPlugin = class {
105
132
  return;
106
133
  }
107
134
  log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
108
- const results = await Promise.allSettled(sourcemaps.map(({ sourcemap }) => flare.uploadSourcemap(sourcemap)));
135
+ const results = await flare.uploadSourcemaps(sourcemaps.map(({ sourcemap }) => sourcemap));
109
136
  const failed = results.filter((r) => r.status === "rejected");
110
137
  if (failed.length > 0) for (const result of failed) compilation.warnings.push(new webpack.WebpackError(`@flareapp/webpack: Upload failed: ${result.reason}`));
111
138
  else log("Successfully uploaded all sourcemaps to Flare.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flareapp/webpack",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Webpack plugin for uploading sourcemaps to Flare",
5
5
  "homepage": "https://flareapp.io",
6
6
  "bugs": "https://github.com/spatie/flare-client-js/issues",