@flareapp/webpack 2.12.0 → 2.12.2

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);
@@ -44,8 +67,10 @@ const RETRIABLE_STATUS_CODES = new Set([
44
67
  429,
45
68
  502,
46
69
  503,
47
- 504
70
+ 504,
71
+ 525
48
72
  ]);
73
+ const MAX_CONCURRENT_UPLOADS = 10;
49
74
  function describeNetworkError(error) {
50
75
  if (!(error instanceof Error)) return String(error);
51
76
  const cause = error.cause;
@@ -69,6 +94,9 @@ var FlareApi = class {
69
94
  sourcemap: base64GzipSourcemap
70
95
  });
71
96
  }
97
+ uploadSourcemaps(sourcemaps) {
98
+ return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
99
+ }
72
100
  async postWithRetry(data, maxRetries = 3) {
73
101
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
74
102
  try {
@@ -134,7 +162,7 @@ var FlareWebpackPlugin = class {
134
162
  return;
135
163
  }
136
164
  log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
137
- const results = await Promise.allSettled(sourcemaps.map(({ sourcemap }) => flare.uploadSourcemap(sourcemap)));
165
+ const results = await flare.uploadSourcemaps(sourcemaps.map(({ sourcemap }) => sourcemap));
138
166
  const failed = results.filter((r) => r.status === "rejected");
139
167
  if (failed.length > 0) for (const result of failed) compilation.warnings.push(new webpack.default.WebpackError(`@flareapp/webpack: Upload failed: ${result.reason}`));
140
168
  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);
@@ -15,8 +38,10 @@ const RETRIABLE_STATUS_CODES = new Set([
15
38
  429,
16
39
  502,
17
40
  503,
18
- 504
41
+ 504,
42
+ 525
19
43
  ]);
44
+ const MAX_CONCURRENT_UPLOADS = 10;
20
45
  function describeNetworkError(error) {
21
46
  if (!(error instanceof Error)) return String(error);
22
47
  const cause = error.cause;
@@ -40,6 +65,9 @@ var FlareApi = class {
40
65
  sourcemap: base64GzipSourcemap
41
66
  });
42
67
  }
68
+ uploadSourcemaps(sourcemaps) {
69
+ return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
70
+ }
43
71
  async postWithRetry(data, maxRetries = 3) {
44
72
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
45
73
  try {
@@ -105,7 +133,7 @@ var FlareWebpackPlugin = class {
105
133
  return;
106
134
  }
107
135
  log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
108
- const results = await Promise.allSettled(sourcemaps.map(({ sourcemap }) => flare.uploadSourcemap(sourcemap)));
136
+ const results = await flare.uploadSourcemaps(sourcemaps.map(({ sourcemap }) => sourcemap));
109
137
  const failed = results.filter((r) => r.status === "rejected");
110
138
  if (failed.length > 0) for (const result of failed) compilation.warnings.push(new webpack.WebpackError(`@flareapp/webpack: Upload failed: ${result.reason}`));
111
139
  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.2",
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",