p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

Incorrect Asset Size Limit Error

Open Qianqianye opened this issue 7 months ago • 8 comments

p5.js version

2.0.3

What is your operating system?

Mac OS

Web browser and version

chrome://146.0.7680.180

Actual Behavior

I tried to upload a small font file(50KB), but received an error indicating that I had exceeded the total asset size limit of 250MB, which blocks the upload. My current total asset size is approximately 68 MB, which is below the stated 250 MB limit. This suggests the limit may be miscalculated or not reflecting actual usage.

Screenshot of the error: Image

Screenshot of the total asset size: Image

Expected Behavior

The upload should succeed, as my total asset usage is below the 250 MB limit.

Steps to reproduce

  1. Navigate to asset upload.
  2. Attempt to upload a small file (e.g., font file).
  3. Observe error message preventing upload.

Qianqianye avatar Apr 15 '26 22:04 Qianqianye

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

welcome[bot] avatar Apr 15 '26 22:04 welcome[bot]

Thanks for flagging this!

@yugalkaushik would you be interested in investigating into this if you have the chance, since you have familiarity with the parts related to the asset limit? I can also take a look into this!

raclim avatar Apr 15 '26 22:04 raclim

@raclim I’ll take a look at it

yugalkaushik avatar Apr 16 '26 08:04 yugalkaushik

I tried reproducing the issue, but everything seems to be working as expected on my end. Could you share any additional details

Image

https://github.com/user-attachments/assets/cc9da564-fc95-48da-8f22-69e1224b4216

yugalkaushik avatar Apr 16 '26 08:04 yugalkaushik

Also following up with other suggestions that could be impacting this:

  • the asset size was being miscalculated beforehand
  • or the previously raised issue where some assets are not being fully deleted from user accounts despite deletion from the 'My Assets' tab. (Currently, there is progress towards asset cleanup but the bug still exists in the codebase)

raclim avatar Apr 16 '26 12:04 raclim

i think i figured out why this happens. the size check on upload is counting every file in s3 for the user, but "my assets" only shows the ones that are actually referenced in a project. so if there are leftover files in s3 from older projects or deletions, they still count against the limit even though you cannot see them.

that matches what @raclim said, the size is effectively miscalculated because of orphans, and the orphans exist because the delete flows don't fully clean up. deleting from my assets removes the s3 file but doesn't touch any db state, removing a file from a project does the opposite, and deleting a full project only cleans up newer s3 files.

that also explains why @yugalkaushik could not reproduce it, a fresh account would not have orphans yet. @Qianqianye probably has some from older deletions.

would love to take this on if it is available! thinking a two part fix, make the size match what the user actually sees, and make sure every delete path cleans up both sides. happy to split into two prs if that helps review.

Nixxx19 avatar Apr 18 '26 17:04 Nixxx19

Hi! I’d like to work on this issue. I’ve gone through the reproduction steps and would like to investigate where the total asset size is being calculated incorrectly and implement a fix. I’ll also test the upload flow locally to make sure the size limit behaves correctly. If the issue is still available, I’d be happy to take it up.

bunny953 avatar Sep 26 '26 06:09 bunny953

Hi everyone. @bunny953 thanks for your interest in the issue. Since the root cause has been addressed in several places, I think it's worth summarising where things stand. #4107, #4119, #4132, #4161, #4162 and #4160 are all patching the same thing from different sides, so putting the picture in one place. This is a long one, bear with me :)

The cause is that S3 and Mongo are separate stores with nothing reconciling them. Each PR closes one path that lets them drift: abandoned sketches and failed clones (#4119, merged), deleting from the Assets tab (#4161), and this issue is what the leftovers look like to a user. On current develop there are still at least four ways an object ends up in <userId>/ with no file referencing it:

  • objects from before #4119 landed
  • deleteProject and file.controller skip S3 for files created before S3_DATE, and getObjectKey returns a bare filename for older URL formats so those deletes miss. S3_DATE isn't documented anywhere in the repo.
  • updateProject removes stale file entries from the database when a full save arrives with fewer files, and never touches S3
  • commitPendingAssets runs before Project.create / findByIdAndUpdate, so a failed save leaves committed objects behind

Any path we haven't thought of yet will leak the same way. Since uploads before save are staying (per @ksen0 on #4107), I think the model should be: pending/ is scratch and the lifecycle rule owns it, and <userId>/ only ever holds objects referenced by a project file URL. Anything else under <userId>/ is garbage regardless of how it got there.

That needs one addition: a reconcile step that lists <userId>/ (paginated, the current call stops at 1000 keys), diffs against the user's project file URLs, and deletes unreferenced objects older than a short grace period. listObjectsInS3ForUser already computes that diff, so it could live there, or in a scheduled job if we'd rather not delete on a read path.

With that in place:

  • Pre-July orphans get swept without a migration, which resolves this issue for older accounts.
  • Quota keeps tracking real S3 usage and matches what the Assets tab shows.
  • #4132 and #4162 become unnecessary. #4132 decouples the quota from storage, #4162 shows uuid-named rows to users for a backend hygiene problem. I'd close both. @ksen0 you linked #4162 as the path forward, so flagging this as a proposal rather than a decision.
  • #4161 stays. It's a real bug on its own (#4160) and gets simpler: every row has a sketch, so no branching on unreferenced assets.

Follow-ups to #4119 that I'd fold into the same PR or a sibling:

  1. Save first, then commit, or delete the committed copies when the save fails.
  2. deleteObjectFromS3 passes any pending/ key through unchanged, so a user can delete another user's pending upload. Should check pending/${userId}/.
  3. Client deleteFile only removes the pending object in the saved-project branch. The unsaved branch, which is where pending objects actually are, just dispatches. This is what @skyyash raised on #4119.

If this reads right, we can move ahead with the reconcile PR. Happy to split it differently if someone sees a reason to keep #4162. @raclim @ksen0 @doradocodes Please correct me if you think I've gone astray anywhere...

Vaivaswat2244 avatar Oct 19 '26 04:10 Vaivaswat2244