posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

Next.js sourcemaps causing throttling issues

Open jakeleventhal opened this issue 1 month ago • 5 comments

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!

jakeleventhal avatar Oct 30 '25 16:10 jakeleventhal

@PostHog/team-error-tracking

marandaneto avatar Nov 01 '25 07:11 marandaneto

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

hpouillot avatar Nov 14 '25 09:11 hpouillot

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.

jakeleventhal avatar Nov 14 '25 11:11 jakeleventhal

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?

daibhin avatar Nov 20 '25 13:11 daibhin

Emailed you @daibhin

jakeleventhal avatar Nov 20 '25 14:11 jakeleventhal