Next.js sourcemaps causing throttling issues
Bug description
Ever since enabling Next.js sourcemaps with PostHog (i.e. using the wrapper in my Next config), I am frequently getting daily throttle issues from Vercel about hitting my file upload limit:
Error: Upload aborted
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
DeploymentError: Too many requests - try again in 2 hours (more than 40000, code: "api-upload-paid").
I could be wrong but the conclusion I'm drawing is the sourcemaps are getting uploaded to Vercel. I did not set the option for deleting sourcemaps after upload, so it should be true by default per the docs. I think maybe what's happening is that the source maps get uploaded to Vercel and then get deleted after.
How to reproduce
Here is my Next config:
import { withPostHogConfig } from "@posthog/nextjs-config";
export default withPostHogConfig(
{...},
{
envId: process.env["POSTHOG_ENV_ID"]!,
host: process.env["NEXT_PUBLIC_POSTHOG_HOST"],
personalApiKey: process.env["POSTHOG_API_KEY"]!,
sourcemaps: {
enabled: !!process.env["NEXT_PUBLIC_SERVER"],
project: "Redacted"
},
},
);
Related sub-libraries
- [ ] All of them
- [ ] posthog-js (web)
- [ ] posthog-js-lite (web lite)
- [ ] posthog-node
- [ ] posthog-react-native
- [ ] @posthog/react
- [ ] @posthog/ai
- [x] @posthog/nextjs-config
Additional context
Thank you for your bug report – we love squashing them!
@PostHog/team-error-tracking
Hi Jake, do you use the vercel CLI from a Github action to deploy ? If so, could you use the option --archive=tgz to see if it solves your issue ?
https://github.com/vercel/community/discussions/4893
Yes, and I'm sure this would solve my issue, but then the problem is Vercel won't cache any files if I do it this way.
I could be wrong but the conclusion I'm drawing is the sourcemaps are getting uploaded to Vercel
@jakeleventhal I would love to verify this because we walked through the code together on our end and couldn't see any reason sourcemaps wouldn't delete. I think I still have access to your codebase but wondering if it would be ok with you if I tried deploying the latest to see the error?
Emailed you @daibhin