Giter Club home page Giter Club logo

Comments (4)

drmikecrowe avatar drmikecrowe commented on July 4, 2024 1

You are right, it won't. Turns out, I had another plugin (serverless-sentry) installed that was duplicating the upload and causing the issue. My bad, sorry for the confusion

from sentry-javascript-bundler-plugins.

lforst avatar lforst commented on July 4, 2024

I am assuming you are uploading source maps for 87 lambdas in quick succession and you are running into our rate limits. Can you try somehow adding a sleep in between the individual builds as a workaround? 1-2 seconds between each build should probably be enough.

I am not sure whether we will increase the rate limit on our API for this use case as it is a bit special I'd say. If the esbuild plugin doesn't work for your use-case you can also use Sentry CLI.

from sentry-javascript-bundler-plugins.

drmikecrowe avatar drmikecrowe commented on July 4, 2024

Sorry @lforst -- I need you guys to do it. I tried to fork/test, but this project is using an EOL version of node that my OS won't install, and trying to use a local version of node-18 gives errors like this:

sentry-javascript-bundler-plugins  main @ 6fd1363 ∽ 30s ❄️ nix-shell-env❯  yarn build
yarn run v1.22.22
$ nx run-many --target=build --all


    ✖  nx run @sentry/babel-plugin-component-annotate:build
$ rimraf ./out && run-p build:rollup build:types
$ rollup --config rollup.config.js
$ tsc --project types.tsconfig.json

       src/index.ts → dist/esm/index.mjs, dist/cjs/index.js...
       created dist/esm/index.mjs, dist/cjs/index.js in 1.4s
       src/index.ts(136,15): error TS2345: Argument of type 'string | null | undefined' is not assignable to parameter of type 'string | null'.
         Type 'undefined' is not assignable to type 'string | null'.

The fix should be simple, but I can't build/test it. Given this is related to your API limits, can I get some help from you guys to test this? This should be pretty close to what we want:

Replace:

          await upload(buildArtifacts);

with:

          const chunkSize = 35;
          const oneMinute = 60 * 1000; // in milliseconds
          for (let i = 0; i < buildArtifacts.length; i += chunkSize) {
            const currentChunk = buildArtifacts.slice(i, i + chunkSize);
            const timeLeft = oneMinute - (Date.now() % oneMinute);
            await upload(currentChunk);
            const sleepTime = Math.max(0, timeLeft - 50); // add some extra 50ms to account for timing inaccuracies
            await new Promise((resolve) => setTimeout(resolve, sleepTime));
          }

Full code for that function

function esbuildDebugIdUploadPlugin(
  upload: (buildArtifacts: string[]) => Promise<void>
): UnpluginOptions {
  return {
    name: "sentry-esbuild-debug-id-upload-plugin",
    esbuild: {
      setup({ initialOptions, onEnd }) {
        initialOptions.metafile = true;
        onEnd(async (result) => {
          const buildArtifacts = result.metafile ? Object.keys(result.metafile.outputs) : [];
          // sentry API appears to have a rate limit of 40 requests per minute -- chunk and finish in batches
          const chunkSize = 35;
          const oneMinute = 60 * 1000; // in milliseconds
          for (let i = 0; i < buildArtifacts.length; i += chunkSize) {
            const currentChunk = buildArtifacts.slice(i, i + chunkSize);
            const timeLeft = oneMinute - (Date.now() % oneMinute);
            await upload(currentChunk);
            const sleepTime = Math.max(0, timeLeft - 50); // add some extra 50ms to account for timing inaccuracies
            await new Promise((resolve) => setTimeout(resolve, sleepTime));
          }
        });
      },
    },
  };
}

from sentry-javascript-bundler-plugins.

lforst avatar lforst commented on July 4, 2024

Two things:

  • I don't think this change will work as you expect because I think you are invoking esbuild 87 times, meaning the onEnd calls are separate and timeouts won't matter. Also, the rate limit is not because we are uploading too many buildArtifacts at once, it is because we are hitting the API too often.
  • We will likely not add an intentional slowdown to clients in order to get around our rate limits. I would like to ask you to adjust your build system instead.

from sentry-javascript-bundler-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.