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

Error stack trace isn't preserved on rethrowing #802

Closed
vyacheslav-sozap opened this issue Mar 4, 2022 · 1 comment
Closed

Error stack trace isn't preserved on rethrowing #802

vyacheslav-sozap opened this issue Mar 4, 2022 · 1 comment

Comments

@vyacheslav-sozap
Copy link

vyacheslav-sozap commented Mar 4, 2022

Description

Runtime: JavaScript. If you catch error (with try/catch) and throw it again, message in log will point to the place of rethrowing, not the original error throwing place. That breaks the error tracing a lot.

Steps to Reproduce

Build and run Nakama with following TypeScript module code:

let TEST_RPC: nkruntime.RpcFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, payload: string): string {
	try {
		throw new Error('test_error');
	} catch (e) {
		throw e;
	}
}

let InitModule: nkruntime.InitModule = function (
    ctx: nkruntime.Context,
    logger: nkruntime.Logger,
    nk: nkruntime.Nakama,
    initializer: nkruntime.Initializer
) {
    initializer.registerRpc('TEST_RPC', TEST_RPC);
}

Expected Result

Error message in log points at line "throw new Error('test_error');"

Actual Result

Error message in log points at line "throw e;"

Your Environment

  • Nakama: 3.10.0
  • Database: PostgreSQL from Docker image postgres:14.1-alpine
  • Environment name and version: Docker image heroiclabs/nakama:3.10.0
  • Operating System and version: WSL2 on Windows 10
@sesposito
Copy link
Member

sesposito commented Mar 25, 2022

This is a limitation of the JS engine we use and it cannot be changed at the moment, but we’ll see if it can be improved in the future.

Related to #801

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

No branches or pull requests

2 participants