What version of Elysia is running?
elysia@1.4.28
What platform is your computer?
Darwin 25.5.0 arm64 arm
What environment are you using
Bun 1.3.14
Are you using dynamic mode?
No
What steps can reproduce the bug?
When sending a WebSocket text frame that contains JSON-like content, Elysia parses the payload before passing it to the .ws() message handler. This means the handler receives an array/object instead of the original text string.
This is a problem when using custom serialize/deserialize tools, because the raw text payload is expected to reach the server unchanged.
Steps to Reproduce
- Create a file with the following code:
import { Elysia } from "elysia"
new Elysia()
.ws("/ws", {
message(_ws, message) {
console.log(message, typeof message)
}
})
.listen(3000)
const ws = new WebSocket("ws://localhost:3000/ws")
ws.onopen = function () {
ws.send('ping')
ws.send('["ping"]')
}
-
Run the file.
-
Check the server output.
What is the expected behavior?
Both sent values are text frames, so the message handler should receive both values as strings:
ping string
["ping"] string
What do you see instead?
The second message is automatically parsed as JSON before reaching the handler:
ping string
[ "ping" ] object
Additional information
No response
Have you try removing the node_modules and bun.lockb and try again yet?
No response
What version of Elysia is running?
elysia@1.4.28
What platform is your computer?
Darwin 25.5.0 arm64 arm
What environment are you using
Bun 1.3.14
Are you using dynamic mode?
No
What steps can reproduce the bug?
When sending a WebSocket text frame that contains JSON-like content, Elysia parses the payload before passing it to the
.ws()message handler. This means the handler receives an array/object instead of the original text string.This is a problem when using custom serialize/deserialize tools, because the raw text payload is expected to reach the server unchanged.
Steps to Reproduce
Run the file.
Check the server output.
What is the expected behavior?
Both sent values are text frames, so the message handler should receive both values as strings:
What do you see instead?
The second message is automatically parsed as JSON before reaching the handler:
Additional information
No response
Have you try removing the
node_modulesandbun.lockband try again yet?No response