Skip to content

[Bug] WebSocket messages received as "[object Blob]" in dev mode #164

@ValentinKolb

Description

@ValentinKolb

Bug Description

As discussed in #163, when sending WebSocket messages in dev mode, the server receives the literal string "[object Blob]" instead of the actual message content.

Steps to Reproduce

// Client code
const socket = new WebSocket('ws://localhost:4321/api/ws');
socket.onopen = () => {
  socket.send("foo");
};

// Server receives: "[object Blob]"
// Expected: "foo"

Environment

  • Using bunx to run dev server
  • astro-bun-websocket with gratelets/bun-websocket package

Root Cause

The issue appears to be related to how the dev middleware handles message conversion when the underlying ws package receives data. The data is incorrectly converted to string, resulting in the default JavaScript object toString representation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions