moorefu opened a new issue #1826:
URL: https://github.com/apache/incubator-apisix/issues/1826


   ### Issue description
   
   
   ### Environment
   
   * apisix version (cmd: `apisix version`):1.3
   * OS: CentOS Linux release 7.8.2003 (Core)
   *  Kernel: 3.10.0-1127.el7.x86_64
   
   ### Minimal test code / Steps to reproduce the issue
   1. create a new serverless route
   ```bash
   curl -i http://127.0.0.1:9080/apisix/admin/routes/1  -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uris": ["/real/abc.json"],
       "plugins": {
           "serverless-pre-function": {
               "phase": "rewrite",
               "functions" : ["return function() ngx.say(\"ok\"); end"]
           }
       },
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "39.97.63.215:80": 1
           }
       }
   }'
   ```
   2. create new plugin: process.lua
   ```lua
   local ngx           = ngx
     local ngx_capture   = ngx.location.capture
     local _M = {
       version = 0.1,
       priority = 9909,     
       type = 'process',   
       name = "process",
       schema = schema,
     }
     function _M.access(conf, ctx)
       local res = ngx_capture("/real/abc.json",{share_all_vars = true,ctx = 
ngx.ctx})
       return res.status_code,res.body
     end
   return _M
   ```
   
   3. create a process route
   
     ```
     curl -i http://127.0.0.1:9080/apisix/admin/routes/2  -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
     {
         "uris": ["/process/abc.json"],
         "plugins": {
             "process": {}
         },
         "upstream": {
             "type": "roundrobin",
             "nodes": {
                 "39.97.63.215:80": 1
             }
         }
     }'
     ```
   
   4. get result
   
      `curl -i http://127.0.0.1:9080/process/abc.json`
   
      `curl -i http://127.0.0.1:9080/real/abc.json`
   
   ### What's the actual result? (including assertion message & call stack if 
applicable)
   first time had not pass opts to capture function。I got an errorlog
   `2020/07/09 23:31:44 [error] 20425#20425: *644502 [lua] init.lua:494: 
http_balancer_phase(): invalid api_ctx while connecting to upstream, client: 
192.168.11.69, server: , request: "GET /process/abc HTTP/1.1", subrequest: 
"/real/abc", host: "192.168.11.13"`
   and then i pass a opts as under,then the error log gone.
   `{share_all_vars = true,ctx = ngx.ctx}`
   
   request the /real/abc.json ,got `ok`, what is the expected. 
   
   but request the  /process/abc.json, got nothing response body is empty.
   
   ### What's the expected result?
   
     ````
   expected result is what the real(/real/abc.json) response ok. 
     ````


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to