Malformed Header Error?

I know that some people are having problems getting R2 Web Edition web apps to run.  I was having the same problem on a few of the more complicated apps I’ve been working on and what made it frustrating was that locally, on my Mac, they ran fine in debug and in as regular web apps.  But on two separate Linux servers (one in CentOS and the other is unknown) they crashed.  I dug into the Error Logs on the servers and kept running across lines like this:

Malformed header from script. Bad header=App.Open

What was in my open event?  Well, I was connecting to the database and upon success opening  a web page and that’s it.  Simple, right?

I was also doing some logging and was calling a method called PrintAndLog which would append whatever string I passed in to a log file and it would send the same message to the console via the Print command.

After much tearing out of hair (and those that know me surely will recognize that I’ve done this a lot!) I commented out ALL the code in App.Open and ran it on the server.  It worked!  So I then started uncommenting code line by line.  Eventually I got to the PrintAndLog call and sure enough that was it.

I then did the same thing in the PrintAndLog method and discovered it was the very first line in the method:

print s

Crazy huh?  Comment out that line and it works again.  What makes it weird is that I’ve used this in multiple places AFTER app.open and it works fine.  So I can only conclude that it has something to do with the application initializing and that print isn’t recommended at that point in time.

Yeah, I agree, it’s a stretch but stranger things have happened. This has been reported <feedback://showreport?report_id=17388> with an example project (the project is private, sorry).  Oh, and this still happens in the R3 beta’s.

So hopefully this might help someone in a similar predicament.