-
Notifications
You must be signed in to change notification settings - Fork 569
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
Cannot set socket.request
to null
because the property is read-only
#696
Comments
jonathanperret
added a commit
to jonathanperret/engine.io
that referenced
this issue
Feb 21, 2024
This was referenced Feb 21, 2024
Merged
darrachequesne
pushed a commit
that referenced
this issue
Feb 23, 2024
Still can't set it to Code: io.on('connection', socket => {
socket.request = null
console.log(socket.request?.session)
}) Output:
|
@sayhicoelho this should work: import { type Socket } from "engine.io";
io.engine.on("connection", (rawSocket: Socket) => {
rawSocket.request = null;
}); In your example: io.on('connection', socket => {
socket.request = null;
})
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The Socket.IO documentation suggests setting the
request
property of thesocket
object received with theconnection
event tonull
. But the types as defined do not allow setting that property from a TypeScript program.To Reproduce
Note that this is a Socket.IO program, because it is taken from the Socket.IO documentation, but it seems clear that the issue comes from the
Socket
type declared in Engine.IO, which is why I'm opening this issue here.Socket.IO server version:
4.7.4
Server
When compiling with
tsc server.ts
here is the result:Expected behavior
The
request
property should not be marked read-only, in order to allow this code to compile.Workaround
Bypassing the restriction works:
The text was updated successfully, but these errors were encountered: