deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

`fastify` does not run in Node compat mode: `server.setTimeout is not a function`

Open GJZwiers opened this issue 3 years ago • 0 comments

// main.mjs
import Fastify from "fastify";

const fastify = Fastify({
  logger: true,
});

// deno-lint-ignore require-await
fastify.get("/", async (_req, _res) => {
  return { hello: "world" };
});

const start = async () => {
  try {
    await fastify.listen({ port: 3000 });
  } catch (err) {
    fastify.log.error(err);
    process.exit(1);
  }
};
start();

deno run --compat --allow-all --unstable main.mjs:

error: Uncaught TypeError: server.setTimeout is not a function
    server.setTimeout(options.connectionTimeout)
           ^
    at getServerInstance (file:///C:/Users/GJZwiers/repos/deno_fastify/node_modules/fastify/lib/server.js:303:12)
    at createServer (file:///C:/Users/GJZwiers/repos/deno_fastify/node_modules/fastify/lib/server.js:15:18)     
    at fastify (file:///C:/Users/GJZwiers/repos/deno_fastify/node_modules/fastify/fastify.js:185:30)
    at file:///C:/Users/GJZwiers/repos/deno_fastify/main.mjs:3:17

server is the return from http.createServer() (Node built-in http module)

GJZwiers avatar Jul 10 '22 11:07 GJZwiers