·5 min read

Exceeds the project size limit": wrong unit

Our editor refused to open a 35.5 MB project file for six days because the budget we watched counted text values, and one constant served as two limits.

testingworkflowarchitecture

Contents

Our editor stopped opening one of our projects with this message:

The local example file is missing or exceeds the project size limit.

The file was there. It was 35,552,489 bytes, and the limit in the check was 33,554,432, which is 32 MiB. It had been over that line for six days, and nothing we ran had told us.

This post is about why. We were watching a size budget the whole time, and it was a real budget with a real number. It measured the wrong thing.

How we found it

A second Claude Code session ran the game to look at something else and noticed that the editor could not load the project. It sent a message to the main session with the facts: the file size, the check in the loader, and the limit it was compared with.

The loader was short. It fetched the project file as text and rejected anything longer than the limit, or anything that started with < (which means the server sent back an HTML error page instead of the file):

const source = await response.text();
if (source.length > platformerProjectFileByteLimit
    || source.trimStart().startsWith('<')) {
  throw new Error('The local example file is missing or exceeds the project size limit.');
}
return JSON.parse(source);

The same message covers two different problems, a missing file and a file that is too big. That made the error easy to misread. The first question anyone asks is whether the file exists, and it did.

The standalone build of the same game, which does not go through the editor loader, kept working the whole time. So every manual test of the game itself passed.

The budget that looked fine

We had a size budget for the project. It counted the characters in the text values stored inside the file, and it said we had about 1.0M characters of room left. That number was true. It just was not the size of the file.

The project stores its art as bitmap data packed into strings, with JSON inside JSON, so the file holds more than the text values the budget counted. The two sizes were different numbers, and only one of them was being watched.

The file grew like this:

  • 31.2 MB on 24 October, under the limit.
  • 35.19 MB at one import step on 29 October, over the limit.
  • 35.46 MB at the next step.
  • 35.55 MB when the side session measured it.

The limit was crossed during the first re-import on 29 October. Each later import made the file larger. The standalone game kept passing our manual checks, so nothing pointed at the file.

Two limits sharing one constant

When we read the limits file, the cause behind the cause was one line:

export const platformerProjectFileByteLimit = platformerSerializationCharacterLimit;

The limit for whole-file size was defined as being the same number as the limit for text values. Someone, at some point, treated them as one thing. The name says bytes, the value comes from a character limit, and the loader compares it with source.length, which counts characters again. Three names, two units, one number.

This is the "wrong unit" bug in a mild form. For plain ASCII, characters and bytes are equal, so it does not bite. It would bite as soon as the file held non-ASCII text. In our case it did not matter, because the file was nearly all ASCII: the character count of the compact form was 35,551,858 against 35,552,489 bytes.

The real problem was larger than the unit. Two different questions, how much text is stored and how big the file is, shared one answer.

The fix

We had three options: make the file smaller, raise the limit, or split the limits. A smaller file means a new format or more packing, which is a bigger change and not one we wanted to do to get the editor open. We split the limits.

  • Whole-file size now has its own limit of 48 MiB. The 32 MiB limit on text values did not change.
  • The import script now stops with an error if the file it publishes goes over 48 MiB, so the next import fails at the point where the file is made, and not days later in an editor.
  • A new test checks the published file against the limit.

After that we loaded the project in the editor. The first room showed with its scenery and enemies, and the browser console had no errors. The file sits at 35.6 of 48 MiB, and the text values have about 1M characters of room. We track both numbers now.

What to take from it

Measure what the check measures. If a loader rejects a file by its length, the budget you watch should be that length. A nearby number that is easier to compute is not a substitute.

Do not reuse one constant for two limits. If two limits happen to be equal today, give them two names. They will not stay equal, and when they split you want the code to already say which is which.

Put the check where the file is made. A limit enforced only when someone opens the file fails late. The importer knew the size of the file it wrote; asking it to fail above the limit costs one line.

Test through the same door users use. The editor's loader was the one path that applied the size limit, and we did not open the project in the editor after each import.

Give different failures different messages. "Missing or exceeds the limit" sent the first look in the wrong direction. A message that said "this file is 35,552,489 bytes, the limit is 33,554,432" would have taken a minute to act on.

The limit itself was not a mistake. A limit on file size is a good idea for a loader that reads the whole file into memory. We had no complaint about 32 MiB. What we got wrong was believing that we were tracking it.

More posts

New writing when there is something worth saying. By email or by RSS, whichever you prefer.