kong icon indicating copy to clipboard operation
kong copied to clipboard

kong.nginx.req_start_time() returns zero in log phase

Open kyriosli opened this issue 2 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Kong version ($ kong version)

2.8.1

Current Behavior

The code in init.lua simply sets the plugin api kong.nginx.req_start_time to ngx.req.start_time, but the log phase was delay-executed after the request has finished, so I think the value of ngx.req.start_time() should be persisted in save_for_later[co] to make it work.

And also some other bugs could be the same reason, for example, when calling kong.request.get_host(), the process check_phase produces an error message, due to the ngx.ctx.KONG_PHASE is empty.

Expected Behavior

kong.nginx.req_start_time() returns right value in log phase

Steps To Reproduce

1. Run kong-gateway:2.8.1
2. Setup a plugin with a `log` phase
3. call `kong.nginx.req_start_time()`

Anything else?

No response

kyriosli avatar Sep 09 '22 05:09 kyriosli