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

🚀 Feature Request: console.trace support #5761

Closed
Cherry opened this issue May 5, 2024 · 1 comment
Closed

🚀 Feature Request: console.trace support #5761

Cherry opened this issue May 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Cherry
Copy link
Contributor

Cherry commented May 5, 2024

Describe the solution

console.trace is a really nice method for logging within functions and getting a stack-trace back to see where and how something was called. In complex workers apps, this would be very helpful.

Reference: https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static

Related: cloudflare/workerd#2247

Contrived example in node.js

console.log('Hello, world!');

function example(){
	console.trace('example');
	return true;
}

function foo(){
	const a = example();
	return a;
}

foo();

Outputs:

Hello, world!
Trace: example
    at example (E:\GitHub\misty-heart-08d6\example.js:5:10)
    at foo (E:\GitHub\misty-heart-08d6\example.js:10:12)
    at Object.<anonymous> (E:\GitHub\misty-heart-08d6\example.js:14:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

which when debugging can be helpful to see when/how things are called.

Today in Workers

Using the following script:

export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
		console.trace('test');

		return new Response('Hello world!');
	},
};

No errors are presented. But you also don't get any logs for the console.trace at all. It's seemingly just swallowed.

@Cherry
Copy link
Contributor Author

Cherry commented May 5, 2024

Opened as a regression instead at cloudflare/workerd#2278

@Cherry Cherry closed this as completed May 5, 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