Closed
Description
Trying to use coroutine.wrap inside of libraries loaded with require
throws an error.
As an example, take this example that creates+uses an iterator:
Contents of wut.lua:
local t = {}
for i in coroutine.wrap(function()
local x
for i=1, 100 do
coroutine.yield(i)
end
end) do
t[i] = i
end
return t
Contents of access.lua (set as access_by_lua_file
):
require "wut"
Running that in openresty results in:
2018/03/28 17:29:25 [error] 16118#0: *1 lua entry thread aborted: runtime error: attempt to yield across C-call boundary
stack traceback:
coroutine 0:
[C]: in function 'require'
./access.lua:1: in function <./access.lua:1>, client: 127.0.0.1, server: , request: "GET /get HTTP/1.1", host: "mynode"
The snippet works fine inside of e.g. access.lua itself.
Metadata
Metadata
Assignees
Labels
No labels