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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 BUG: console.trace support (regression) #5762

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

馃悰 BUG: console.trace support (regression) #5762

Cherry opened this issue May 5, 2024 · 1 comment
Labels
bug Something that isn't working

Comments

@Cherry
Copy link
Contributor

Cherry commented May 5, 2024

Which Cloudflare product(s) does this pertain to?

Wrangler core

What version(s) of the tool(s) are you using?

3.53.1

What version of Node are you using?

20.12.2

What operating system and version are you using?

Windows 11

Describe the Bug

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

Observed behavior

console.trace calls are swallowed and log nothing.

Expected behavior

A trace should be logged, like in versions <= 3.14.0:

Trace: test
    at logConsoleMessage (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:128126:25)
    at WebSocket2.<anonymous> (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:127835:13)
    at callListener (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:107228:18)
    at WebSocket2.onMessage (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:107163:13)
    at WebSocket2.emit (node:events:530:35)
    at Receiver2.receiverOnMessage (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:108231:24)
    at Receiver2.emit (node:events:518:28)
    at Receiver2.dataMessage (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:106513:18)
    at Receiver2.getData (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:106442:21)
    at Receiver2.startLoop (C:\Users\james\AppData\Local\npm-cache\_npx\51f9f4bffffff67a\node_modules\wrangler\wrangler-dist\cli.js:106183:26)

(arguably not that useful since that's not userland code, but at least you get something)

Steps to reproduce

Using the following script:

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

		return new Response('Hello world!');
	},
};
  • npx wrangler@3.14.0 dev - logs a trace
  • npx wrangler@3.15.0 dev - no trace, no error, just swallowed
  • npx wrangler@3.53.1 dev - no trace, no error, just swallowed

I previously opened this as a feature request at #5761, but have since realised this is a regression.

Related: #4300

@Cherry Cherry added the bug Something that isn't working label May 5, 2024
@Cherry
Copy link
Contributor Author

Cherry commented May 5, 2024

As a workaround, I'm using:

console.log(new Error().stack)

which is okay... but it is littered with a tonne of middleware and facades that are of no relevance to me directly:

Error
    at foo (file:///E:/GitHub/misty-heart-08d6/src/index.ts:4:16)
    at Object.fetch (file:///E:/GitHub/misty-heart-08d6/src/index.ts:6:3)
    at fetchDispatcher (file:///E:/GitHub/misty-heart-08d6/.wrangler/tmp/bundle-owSc75/middleware-loader.entry.ts:56:17)
    at __facade_invokeChain__ (file:///C:/Users/james/AppData/Local/npm-cache/_npx/357954942dbe55d3/node_modules/wrangler/templates/middleware/common.ts:53:9)
    at Object.next (file:///C:/Users/james/AppData/Local/npm-cache/_npx/357954942dbe55d3/node_modules/wrangler/templates/middleware/common.ts:50:11)
    at jsonError (file:///C:/Users/james/AppData/Local/npm-cache/_npx/357954942dbe55d3/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:30)
    at __facade_invokeChain__ (file:///C:/Users/james/AppData/Local/npm-cache/_npx/357954942dbe55d3/node_modules/wrangler/templates/middleware/common.ts:53:9)
    at Object.next (file:///C:/Users/james/AppData/Local/npm-cache/_npx/357954942dbe55d3/node_modules/wrangler/templates/middleware/common.ts:50:11)
    at drainBody (file:///C:/Users/james/AppData/Local/npm-cache/_npx/357954942dbe55d3/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:30)
    at __facade_invokeChain__ (file:///C:/Users/james/AppData/Local/npm-cache/_npx/357954942dbe55d3/node_modules/wrangler/templates/middleware/common.ts:53:9)

In production with wrangler tail, I do get something reasonable with this workaround:

  (log) Error
    at foo (index.js:5:19)
    at Object.fetch (index.js:7:5)

but console.trace calls are just swallowed in production too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant