-
Notifications
You must be signed in to change notification settings - Fork 2.1k
No error logging on coroutine.resume (pull-request for issue #951) #952
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
Changes from 3 commits
3da880a
650b81a
7ede2ea
23189a0
3e1d561
f4d07dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ use Test::Nginx::Socket::Lua; | |
|
||
repeat_each(2); | ||
|
||
plan tests => repeat_each() * (blocks() * 3 + 5); | ||
plan tests => repeat_each() * blocks() * 3 + 4; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better keep the parens otherwise we need to update this plan every time we change the repeat_each number. Also, the repeat each number is automatically increased on the "check leak" test mode of Test::Nginx::Socket, and your change will break the test plan in that test mode. |
||
|
||
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8'; | ||
|
||
|
@@ -281,7 +281,7 @@ GET /lua | |
end) | ||
end | ||
|
||
N = 10 | ||
N = 10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better avoid unrelated changes to make your changeset atomic. It's better for version control. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think my editor did it automatically. I will add that space back. |
||
x = gen(N) -- generate primes up to N | ||
while 1 do | ||
local n = x() -- pick a number until done | ||
|
@@ -483,8 +483,8 @@ done | |
GET /lua | ||
--- response_body | ||
hello | ||
--- error_log eval | ||
["stack traceback:", "coroutine 0:", "coroutine 1:", "coroutine 2:"] | ||
--- no_error_log | ||
[error] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, the indentation of this test case is to test the Lua land backtrace. After your change, we no longer have any tests designed for this purpose. I'm not sure if silencing the error logging is a good idea. Maybe we can make it a lower log level like "warn" or even "info"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, better check the return values of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
|
||
|
||
|
@@ -901,8 +901,8 @@ qr/^child: resume: falsecontent_by_lua\(nginx\.conf:\d+\):4: bad | |
child: status: dead | ||
parent: status: running | ||
$/s | ||
--- error_log eval | ||
qr/lua coroutine: runtime error: content_by_lua\(nginx\.conf:\d+\):4: bad/ | ||
--- no_error_log | ||
[error] | ||
|
||
|
||
|
||
|
@@ -1315,4 +1315,3 @@ co yield: 2 | |
|
||
--- no_error_log | ||
[error] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned earlier, should we just lower the log level here? Like
info
?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do so, this will be different than what Lua / LuaJIT does. They don't write anything. I mean, OpenResty doesn't log anything when wrapping code with
pcall
. If you want to log errors even when they are raised in a code wrapped withpcall
, then I would consider having this logged as well, and of course we need to changepcall
then as well. This would differ from what users' expect, though. My only concern is that I'm not sure if that removed log entry removes error logging also from some case where it shouldn't. That's why I asked do anyone of you know if it is only handling when users' code callscoroutine.resume
(that's the only place where this logging should be silenced).But I probably wouldn't worry too much if this is lowered to
INFO
or evenDEBUG
. Some library writers can rely on this, e.g. exiting coroutines witherror
and then handling the errors themselves. If this means that the logs will be filled with these messages, then that could be a problem. E.g. my routing library is relying on coroutines and it will by default log the errors from coroutine.resume, so this would mean that errors are logged twice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bungle
pcall
is a more explicittry/catch
in the Lua world while many Lua programmers may overlook the error handling incoroutine.resume
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agentzh, I agree, but that's how the Lua is. Those that use
coroutine.resume
should know that it is effectively apcall
. There is some history to this aspcall
has not been fully compatible with coroutines (http://lua-users.org/wiki/PcallAndCoroutines).