Core.msleep not working in http-resp (http-response)?

I am testing a simple way to delay a response using lua in haproxy 1.6.3. Lua script:

function delay_response(txn)
  core.msleep(2)
end

core.register_action("delay_response", { "http-res" }, delay_response);

called like this:

backend be
 http-response lua.delay_response

However, this just hangs when invoked. Changing the script to just something in the response works fine, e.g.:

function delay_response(txn)
  txn.res:send("HTTP/1.0 200 OK\r\n")
  txn:done()
end

The same thing happens if the http-response is placed in the frontend section of the config.

Any ideas?