Skip to content
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

TypeScript: Cannot use Http2SecureServer #4494

Closed
zefir-git opened this issue Oct 14, 2022 · 3 comments
Closed

TypeScript: Cannot use Http2SecureServer #4494

zefir-git opened this issue Oct 14, 2022 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@zefir-git
Copy link

zefir-git commented Oct 14, 2022

Describe the bug
The documentation indicates the following code for server initialisation with http2:

import { createSecureServer } from "http2";
import { Server } from "socket.io";

const httpServer = createSecureServer({...});

const io = new Server(httpServer, { /* options */ });

httpServer is http2.Http2SecureServer
when calling new Server(httpServer, {}), TS2769: No overload matches this call. None of the signatures accepts Http2SecureServer.

The full error is:

TS2769: No overload matches this call.
   Overload 1 of 3, '(srv?: number | import("http").Server<...> | import("https").Server<...> | undefined, opts?: Partial<...> | undefined): Server<...>', gave the following error.
     Argument of type 'Http2SecureServer' is not assignable to parameter of type 'number | Server<...> | Server<...> | undefined'.
       Type 'Http2SecureServer' is missing the following properties from type 'Server<typeof IncomingMessage, typeof ServerResponse>': closeAllConnections, closeIdleConnections, maxHeadersCount, maxRequestsPerSocket, and 4 more.
   Overload 2 of 3, '(srv: number | import("http").Server<...> | import("https").Server<...> | Partial<...> | undefined, opts?: Partial<...> | undefined): Server<...>', gave the following error.     Argument of type 'Http2SecureServer' is not assignable to parameter of type 'number | Server<...> | Server<...> | Partial<...> | undefined'.
       Type 'Http2SecureServer' is not assignable to type 'Server<typeof IncomingMessage, typeof ServerResponse>'.

To Reproduce

Please fill the following code example:

Socket.IO server version: 4.5.2

Server

(copy-pasted 1:1 from https://socket.io/docs/v4/server-initialization/#with-an-http2-server for TypeScript)

import { readFileSync } from "fs";
import { createSecureServer } from "http2";
import { Server } from "socket.io";

const httpServer = createSecureServer({
	allowHTTP1: true,
	key: readFileSync("/path/to/my/key.pem"),
	cert: readFileSync("/path/to/my/cert.pem")
});

const io = new Server(httpServer, { /* options */ });

Platform:

  • Device: Razer Book 13
  • OS: Ubuntu 22.04 LTS
  • Node.js: v16.17.1
  • npm: 8.15.0
@zefir-git zefir-git added the to triage Waiting to be triaged by a member of the team label Oct 14, 2022
@darrachequesne
Copy link
Member

Hi! Thanks for the heads-up 👍

This should be fixed by d3d0a2d (awaiting release).

@darrachequesne darrachequesne added bug Something isn't working and removed to triage Waiting to be triaged by a member of the team labels Oct 14, 2022
@zefir-git
Copy link
Author

Thank you. Looking forward to the release

@darrachequesne
Copy link
Member

Included in 4.5.3. Thanks for the heads-up 👍

@darrachequesne darrachequesne added this to the 4.5.3 milestone Oct 15, 2022
dzad pushed a commit to dzad/socket.io that referenced this issue May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants