Skip to content

Commit

Permalink
Upload 5 source maps artifacts in parallel for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
arabold committed Jun 22, 2022
1 parent 2ae2dd2 commit 2e0dcda
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"serverless-sentry-lib": "2.x.x"
},
"dependencies": {
"@supercharge/promise-pool": "^2.3.0",
"adm-zip": "^0.5.9",
"semver": "^7.3.2",
"superagent": "^7.1.6",
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from "path";

import { PromisePool } from "@supercharge/promise-pool";
import * as AdmZip from "adm-zip";
import * as SemVer from "semver";
import Serverless from "serverless";
Expand Down Expand Up @@ -443,7 +444,7 @@ export class SentryPlugin implements Plugin {
return;
}

this.serverless.cli.log("Uploading sourcemaps to sentry", "sentry");
this.serverless.cli.log("Uploading source maps to Sentry", "sentry");

const artifacts = new Set(
this.serverless.service
Expand All @@ -464,11 +465,10 @@ export class SentryPlugin implements Plugin {
});
});

// Upload artifacts one after the other
await results.reduce(
(previousPromise, nextArtifact) => previousPromise.then(() => nextArtifact()),
Promise.resolve(),
);
// Upload artifacts
await PromisePool.withConcurrency(5)
.for(results)
.process(async (nextArtifact) => await nextArtifact());
}

async _uploadSourceMap(entry: AdmZip.IZipEntry, params: ApiParameters): Promise<void> {
Expand Down

0 comments on commit 2e0dcda

Please sign in to comment.