Skip to content

std/http/server.ts>serve is deprecated, io.handler() is incompatible with Deno.serve #17

Closed
@svdvonde

Description

@svdvonde

Describe the bug

Deno's std/http/server.ts>serve is deprecated and will be removed in version 1.0.0. Instead they suggest to use Deno.serve.

This library currently does not seem to be compatible with Deno.serve. It throws the following error:

Deno: No overload matches this call. Overload 1 of 3, '(handler: ServeHandler): Server', gave the following error. Argument of type '(req: Request, connInfo: ConnInfo) => Response | Promise' is not assignable to parameter of type 'ServeHandler'. Overload 2 of 3, '(options: ServeInit & (ServeOptions | ServeTlsOptions)): Server', gave the following error. Argument of type '(req: Request, connInfo: ConnInfo) => Response | Promise' is not assignable to parameter of type 'ServeInit & (ServeOptions | ServeTlsOptions)'.

To Reproduce

deps.ts

export * as socketio from "https://deno.land/x/socket_io@0.2.0/mod.ts";

test.ts

import { socketio } from "./deps.ts";
const io = new socketio.Server();
Deno.serve(io.handler());

Expected behavior

Ideally I would expect the socketio handler to be compatible with Deno.serve.

Platform:

MacOS 13.5 (Intel-based)
deno 1.35.3 (release, x86_64-apple-darwin)
v8 11.6.189.12
typescript 5.1.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions