Hi all,
I've been using Openresty with moonscript (and lapis). I had been compiling my .moon files to .lua, but I was getting annoyed with that, as it's an extra step and extra files to deal with.
`require "moonscript"` is supposed to patch the global `require` to understand moonscript, which makes things much more convenient usually, so I tried that first:
#nginx.conf
init_by_lua 'require "moonscript"'
...
content_by_lua '
local M = require "my_moonscript_module"
...
'
This fails, giving me the following error message:
lua entry thread aborted: runtime error: attempt to yield across C-call boundary
stack traceback:
coroutine 0:
[C]: in function 'require'
...
That confused me, because I thought LuaJIT didn't have a problem with C call boundaries. In any case, I added a preload `require "my_moonscript_module"` after the `require "moonscript"` in this init code, to try to evade the problem. This gave me another error:
nginx: [error] failed to run init_by_lua*: /usr/share/lua/5.1/moonscript/compile.lua:687: no request found
stack traceback:
[C]: in function 'create'
/usr/share/lua/5.1/moonscript/compile.lua:687: in function 'tree'
...
Tracing that down, I found a call to coroutine.create, which is overridden by ngx_lua. I was able to duplicate the problem like this:
init_by_lua '
c = coroutine.create(function ()
--whatever
end)
coroutine.resume(c)
'
This gave me the same error. I assume the patched coroutine functions look for the ngx object to do some black magic with light threads, but this means you can't use coroutines in init_by_lua*, which is bad.
So to recap, I need a fix for at least one of these problems:
* requireing a moonscript module gives me an error about yielding across a C boundary.
* preloading a moonscript module involves using coroutines, which are not available in init_by_lua*
Does anyone have a workaround? In the mean time it's back to precompiling moonscript files...
Thanks,
/wolf