cloudflare / workerd

The JavaScript / Wasm runtime that powers Cloudflare Workers

Home Page:https://blog.cloudflare.com/workerd-open-source-workers-runtime/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› BUG: Logging a websocket message from a durable object logs a scary warning

threepointone opened this issue Β· comments

Which Cloudflare product(s) does this pertain to?

Wrangler core, Miniflare

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

wrangler@3.15.0

What version of Node are you using?

v18.19.0

What operating system and version are you using?

Mac OS

Describe the Bug

Observed behavior

I made a Durable Object, and connected to it with a websocket. The object responds to 'ping' with 'pong'. Pretty simple. Logging the event in the message handler logs a super scary warning

<Formatting threw (Error: Failed to get the 'ports' property on 'MessageEvent': the property is not implemented.
    at MessageEvent.formatJsgResourceType (node-internal:internal_inspect:2188:31)
    at formatValue (node-internal:internal_inspect:660:49)
    at inspect (node-internal:internal_inspect:246:12)
    at formatWithOptionsInternal (node-internal:internal_inspect:2047:44)
    at formatWithOptions (node-internal:internal_inspect:1916:12)
    at formatLog (node-internal:internal_inspect:2136:16)
    at null.<anonymous> (file:///***/src/index.ts:48:13)>

Expected behavior

It probably shouldn't log that warning? If that field hasn't been implemented yet it should probably just be ignored.

Steps to reproduce

Please provide a link to a minimal reproduction

https://github.com/threepointone/scary-wrangler-error-log

Please provide any relevant error logs

No response

Hey! πŸ‘‹ Thanks for reporting this. Yeah, this definitely shouldn't be happening. Will transfer this to workerd since that's where the problem is, but should be able to fix this. πŸ‘

getting same issue

image

When I run this on wrangler@3.14.0 I get

MessageEvent {
  data: undefined,
  ports: undefined,
  source: undefined,
  lastEventId: undefined,
  origin: undefined
}

But it breaks on wrangler@3.15.0 or greater.

@mrbbot it looks like you made a few changes to console.log() in both workers-sdk and workerd that went into that release. Sorry for the tag if you're already looking into it, just commenting since I was assigned to this issue at some point.

No worries, just put a PR up to fix this: #1679 πŸ™‚ This is definitely an issue with the util.inspect() implementation, not WebSockets specifically. πŸ‘