Cannot perform %TypedArray%.prototype.set on a detached ArrayBuffer when using with uWebSockets #4281
-
Hey
Here is the example I used: server.js: const { App } = require("uWebSockets.js");
const { Server } = require("socket.io");
const app = new App();
const io = new Server({ cors: {
origin: "*",
methods: ["GET", "POST", "PUT"]
}});
io.attachApp(app);
io.on("connection", (socket) => {
// ...
});
app.listen(9000, (token) => {
if (!token) {
console.warn("port already in use");
}
}); demo.html <!doctype html>
<html>
<head>
<title>Socket.IO uWS</title>
</head>
<script src="node_modules/socket.io/client-dist/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
$(function () {
var socket = io(
'ws://127.0.0.1:9000',
{
// transports: ["websocket"] // ----> it works if you add this
});
socket.onAny((eventName, ...args) => {
console.log("received event: " + eventName);
});
});
</script>
<body>
</body>
</html> Any idea about this issue ? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 4 replies
-
Hi! I was not able to reproduce the issue with the code you provided. Could it be linked to the Node.js version (v17.0.1)? Could you please try with latest v16 for example? |
Beta Was this translation helpful? Give feedback.
-
Hey, I tried with Node version {
"name": "uws",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"socket.io": "^4.4.1",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.6.0"
}
}
|
Beta Was this translation helpful? Give feedback.
-
@darrachequesne |
Beta Was this translation helpful? Give feedback.
-
@darrachequesne You are doing this wrong on this line https://github.com/socketio/engine.io/blob/a463d268ed90064e7863679bda423951de108c36/lib/transports-uws/polling.ts#L158 You are trying to concat Buffer views of arrayBuffers that are already gone. Allocate a buffer with correct size and copy arrayBuffers to it |
Beta Was this translation helpful? Give feedback.
-
@darrachequesne any update on this ? thanks. |
Beta Was this translation helpful? Give feedback.
-
This should be fixed by socketio/engine.io@3367440, included in In Safari, the server did receive two chunks during the Socket.IO handshake, the first being empty:
|
Beta Was this translation helpful? Give feedback.
This should be fixed by socketio/engine.io@3367440, included in
[email protected]
.In Safari, the server did receive two chunks during the Socket.IO handshake, the first being empty: