-
-
Notifications
You must be signed in to change notification settings - Fork 690
fix(websocket): add Uint8Array
to WSMessageReceive
#4036
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
Conversation
Bundle size check
Compiler Diagnostics
Reported by octocov |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4036 +/- ##
=======================================
Coverage 91.32% 91.32%
=======================================
Files 168 168
Lines 10684 10684
Branches 3032 3062 +30
=======================================
Hits 9757 9757
Misses 926 926
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hey @nakasyou Can you review this? |
I think it is not Web Standard. And existing code may break. For example: upgradeWebSocket({
async onMessage(evt) {
let text: string
if (evt.data instanceof ArrayBuffer) {
text = decoder.decode(new Uint8Array(evt.data))
} else {
// process as blob
text = await evt.data.text() // TypeScript will throw an error
}
}
}) So, an idea, how about using this approach? |
Great! But the test will fail: But I think |
Yes, I agree with you.
Of course! Check honojs/middleware#1094. |
We follow the honojs/middleware#1094 instead of this PR. Closing. |
This will fix the issue pointed out in honojs/middleware#1077 (review)
In @hono/node-ws, the
data
in the link can beBuffer
:https://github.com/honojs/middleware/blob/b18f24379bb4a1350d0b1da0cb109787dddc5193/packages/node-ws/src/index.ts#L116
But currently,
WSMessageReceive
can not beBuffer
and the type error throws:So I added the
Uint8Array
, which is the superclass ofBuffer
toWSMessageReceive
.The author should do the following, if applicable
bun run format:fix && bun run lint:fix
to format the code