Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn compatibility function causes write guard warning in OpenResty #412

Closed
piotrp opened this issue Jan 13, 2022 · 2 comments · Fixed by #414
Closed

warn compatibility function causes write guard warning in OpenResty #412

piotrp opened this issue Jan 13, 2022 · 2 comments · Fixed by #414

Comments

@piotrp
Copy link
Contributor

piotrp commented Jan 13, 2022

Loading Penlight in OpenResty gives me a warning on stdout:

[warn] 19#19: *2 [lua] _G write guard:12: __newindex(): writing a global Lua variable ('warn') which may lead to race conditions between concurrent requests, so prefer the use of 'local' va
riables
stack traceback:
        /usr/lib/openresty/luajit/share/lua/5.1/pl/compat.lua:230: in main chunk
        [C]: in function 'require'
        /usr/lib/openresty/luajit/share/lua/5.1/pl/utils.lua:9: in main chunk
        [C]: in function 'require'
        /usr/lib/openresty/luajit/share/lua/5.1/pl/pretty.lua:12: in main chunk
        [C]: in function 'require'

Would it be possible to set it using rawset, i.e. change its definition from

function warn(arg1, ...) -- luacheck: ignore

to

local function warn(arg1, ...)
...
end
rawset(_G, "warn", warn)

? It would make it compatible with current versions of OpenResty.

@Tieske
Copy link
Member

Tieske commented Jan 14, 2022

can you sent a PR please?

2 caveats;

  • make sure the docs still render properly
  • please add a comment that it's a workaround for OpenResty

@piotrp
Copy link
Contributor Author

piotrp commented Jan 14, 2022

Done, it doesn't change anything in docs as the change is contained within enclosing code block (and I verified it by generating docs in my branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants