oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.94k stars 2.75k forks source link

Using pino-pretty as transport with fastify leads to crash #13705

Closed binamralamsal closed 1 month ago

binamralamsal commented 1 month ago

What version of Bun is running?

1.1.27

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

This is my code

import Fastify from "fastify";

const fastify = Fastify({
  logger: {
    // Bug in bun
    transport: {
      target: "pino-pretty",
    },
  },
});

fastify.get("/", (request, reply) => reply.send("Hello"));

try {
  await fastify.listen({ port: 3001 });
  console.log("Server listening on port 3001");
} catch (err) {
  fastify.log.error(err);
  process.exit(1);
}

It only happens when you include this line:

transport: {
  target: "pino-pretty",
},

If I comment it, it works fine.

What is the expected behavior?

The expected behavior is for fastify to use pino-pretty when logging into the console.

What do you see instead?

$ bun src/index.ts
Server listening on port 3001
============================================================
Bun Canary v1.1.27-canary.66 (c50f8d82) Windows x64
Windows v.win10_fe
CPU: sse42 avx avx2
Args: "C:\Users\ASUS\.bun\bin\bun.exe" "src/index.ts"
Features: jsc dotenv(2) http_server(2) tsconfig(10) 
Builtins: "bun:main" "node:assert" "node:async_hooks" "node:buffer" "node:dns" "node:events" "node:fs" "node:http" "node:https" "node:module" "node:os" "node:path" "node:stream" "node:string_decoder" "node:tty" "node:url" "node:util" "node:util/types" "node:worker_threads" "node:diagnostics_channel" 
Elapsed: 365ms | User: 46ms | Sys: 31ms
RSS: 0.22GB | Peak: 0.22GB | Commit: 0.29GB | Faults: 53448

panic(thread 19264): Cast 512[handle] -> FDImpl.UV makes closing impossible!

The supplier of this FileDescriptor should call 'bun.toLibUVOwnedFD'
or 'FDImpl.makeLibUVOwned', probably where open() was called.
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.27/wa2c50f8d8AioghgC07lnQqplr3C__i8k3yBA0eNo1zbEKwjAURuG9T/E7VUELCq4uloIguFgXcUiaqwne5obcluLbi6LzgfPtjQ7YrjdXb6JjumG1Q1Mf+sRVe0FvnqToWDTEB0KfRDVYpllRnD1Bx5Q4UIbcMfigaAJTTdrlkAbJUC8jO3SGGaUdYzXIMdj2cpoiuaYuC8kof9qH+kdy5RIpizWWX5g8ZYIkivMFJqPfH7nqDZl9QLA

error: script "start" exited with code 3

Additional information

No response

Jarred-Sumner commented 1 month ago

Duplicate of https://github.com/oven-sh/bun/issues/13653

Jarred-Sumner commented 1 month ago

This will get fixed, but we are tracking it in https://github.com/oven-sh/bun/issues/13653