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

Add better stacktrace #3736

Open
1 task done
CrosRoad95 opened this issue Sep 19, 2024 · 0 comments
Open
1 task done

Add better stacktrace #3736

CrosRoad95 opened this issue Sep 19, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@CrosRoad95
Copy link
Contributor

CrosRoad95 commented Sep 19, 2024

Is your feature request related to a problem? Please describe.

Using functions with callback cause stacktrace to be reseted - if this is even correct word, in example below you don't know what caused potential bug. On big servers it can be problematic.

function foo()
    setTimer(function()
        setTimer(function()
            -- INFO: stack traceback:
	        -- stacktrace\server.lua:6: in function <stacktrace\server.lua:3>
            print(debug.traceback())
        end, 10, 1)
    end, 10, 1)
end

addEvent("foo")
addEventHandler("foo", root, foo)

triggerEvent("foo", root)

Describe the solution you'd like

Implement function like "getStackTrace" and option to enable/disable showing stacktraces during errors/warnings - server side mtaserver.conf configuration like:

<developmentMode>
  <enabled>true</enabled> -- set to "false" in production
  <errorLogging>stacktraces<errorLogging>
  <warningLogging>stacktraces<warningLogging>
</developmentMode>

Server and client should be able to append stacktrace data therefore you know origin of error even if it happened in different resource on other side

Describe alternatives you've considered

Use forks

Additional context

After that you code above print more or less how javascript prints errors:

stack traceback:
	stacktrace\server.lua:14: in triggered event
	stacktrace\server.lua:2: in setTimer
	stacktrace\server.lua:3: in setTimer
	stacktrace\server.lua:6: in function <stacktrace\server.lua:3>

and in more complex examples: cross-resource, across-network stacktrace should add annotations and look like:

	stacktrace\client.lua:10: triggered network event 
	stacktrace\server.lua:14: from network triggered event
	stacktrace\server.lua:2: in setTimer
	stacktrace\server.lua:3: in setTimer
	stacktrace\server.lua:6: transition to other resource
	otherResource\server.lua:6: in function <otherResource\server.lua:3>

Security Policy

  • I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
@CrosRoad95 CrosRoad95 added the enhancement New feature or request label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant