Skip to content

Commit

Permalink
fix(runloop) propagate Lua errors from coroutine.wrap()
Browse files Browse the repository at this point in the history
It seems like ngx_lua's `corouting.wrap()` does not propagate Lua errors
to the parent thread like PUC-Lua or LuaJIT's coroutine do - this seems
to be an oversight for which a fix is currently being designed.

This ensures Lua errors happening inside plugins' access phase propagate
to the ngx_lua entry thread.
  • Loading branch information
thibaultcha committed Jan 19, 2018
1 parent 6dc751a commit 38580ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kong/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ function Kong.access()

for plugin, plugin_conf in plugins_iterator(singletons.loaded_plugins, true) do
if not ctx.delayed_response then
coroutine.wrap(plugin.handler.access)(plugin.handler, plugin_conf)
local err = coroutine.wrap(plugin.handler.access)(plugin.handler, plugin_conf)
if err then
ctx.delay_response = false
return responses.send_HTTP_INTERNAL_SERVER_ERROR(err)
end
end
end

Expand Down

0 comments on commit 38580ff

Please sign in to comment.