At INOC, my place of work, I work on a lot of web applications with the backend written in Perl using Catalyst, and the frontend written in Javascript using ExtJS. With a UI written completely in Javascript, I often encounter bugs of the following form:

  1. Fire up Catalyst.
  2. Login.
  3. Click through half a dozen controls in the UI.
  4. Enter some data.
  5. Click “submit”.
  6. Watch the web application give you an angry error.

As you can imagine, the time for a single iteration of this cycle is fairly long, and the process is quite tedious. Obviously, if the error lies within the Javascript side, there's not much I can do about it, short of writing a Greasemonkey script to do some of the automation for me. However, half of the time, the server is returning some strange output given a certain set of inputs for a particular RPC call. Wouldn't it be nice if you could go through the application and have it record the requests you make to be submitted over and over again at a later time?

That's why I wrote Plack-Middleware-Recorder.

Plack-Middleware-Recorder is a distribution that comes with several modules:

These modules allow you to build PSGI applications and scripts that record and replay requests to a web application. However, Plack-Middleware-Recorder also contains two scripts, plack-record and plack-replay, that do exactly what they sound like. So my workflow for handling a server-side bug goes from this:

  1. Steps 1 - 6 above
  2. Add some debugging log output
  3. Repeat, and observe the new output

to this:

  1. plack-record > requests.out
  2. Steps 1 - 6
  3. Add some debugging log output
  4. plack-replay requests.out app.psgi
  5. GOTO 3

Plack-Middleware-Recorder is still very young; I plan on adding better session support, dumping request streams to test files, and other features in the future. In the week since I've written it, I've already gotten a lot of mileage out of it; I hope other people find it just as useful!


Published on 2011-10-17