The “you broke the build!” game
Recently I pulled some code from a colleague, and tried to test it. It worked, which was fine, so I let it run the tests, and went out to lunch.
When I came back, I was surprised to discover that the build has failed, not because of some test failing, but because it couldn’t compile. To be rather more exact, we go the following error:
[optimized-build] Using type script compiler: C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\tsc.exe [optimized-build] [optimized-build] System.ComponentModel.Win32Exception thrown: [optimized-build] -------------------------- [optimized-build] The filename or extension is too long [optimized-build] --------------------------
That was strange. I checked several times, and we had no such thing. No one had a veryVeryLongFileNameThatNeededToBeVeryExplicitAboutWhatItWasDoingAndDidNotCareAboutLength.ts.
And the tsc.exe location was in its normal place. This is from a part in our build process that gather all the TypeScript files and merge them into a single optimized bundle. And it suddenly failed. Now, on the colleague machine, it worked. The previous commit before I merged it, it worked. The merge was a clean one, and very obvious that nothing was going on there.
It took me a while, but I finally figured out that the error occurred because my colleague has added a new TypeScript file.
How can adding a file break the build?
As it turns out, the code we were calling did something like this:
tsc.exe file1.ts file2.ts file3.ts
And at some point, the size of the command line we were passing to the process has exceeded 32KB. And that is when everything broke loose.
Luckily, we were able to write those things to a file and ask the compiler to load them directly, instead of passing them via the command line:
tsc.exe @arguments.txt
And everything was okay again…
Comments
Nice. This once again proves that a clean merge result is not a guarantee for success.
32KB limit? This just shouldn't be happening in the 21st century.
@Jason - What are you passing on the command line that 32KB isn't enough? At some point, a human being will have to read it it (most likely because something broke), and that task will be much more difficult with a gigantic command line.
@Chris - Personally, nothing. However I would counter your point as follows:
I would consider using a tsconfig.json file to configure the tsc with all those things you need to tell him.
I second Frank's, these days your best option is to use a tsconfig.json file and just call tsc plain. The additional benefit to a tsconfig.json file is that it is also friendly to anyone wanting to use Atom or VSCode to work on your TypeScript files.
Two details : - The file names were probably with the full path, which explains how a 32K line can occur, and why a different root directory on the build server means a different line length - I had the same kind of error with ResGen.exe, but the actual culprit was a bug in an MsBuild task, that should have split the line but did not do so if the limit is reached exactly on the last element of the line
Jean-Jacques, We were actually using relative paths. It is just that we really have that many files
Comment preview