Skip to content

[engine.io] _query should be optional #5468

@BlueskyFR

Description

@BlueskyFR

Hi!

Following the Nuxt tutorial (https://socket.io/how-to/use-with-nuxt) and as a follow-up on this ( #5323 ) unanswered discussion, I think the following line/variable _query should be made optional:

_query: Record<string, string>;

Since handleRequest() in:

this.prepare(req);

calls prepare(), which sets the _query field even if it doesn't exist yet:

private prepare(req: EngineRequest) {
// try to leverage pre-existing `req._query` (e.g: from connect)
if (!req._query) {
const url = new URL(req.url, "https://socket.io");
req._query = Object.fromEntries(url.searchParams.entries());
}
}

And my editor currently complains about the types mismatch after completing the above mentionned tutorial:

Image

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions