Unix socket bind may delete an existing file when binding fails

Cerrado
#3,781 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

@abhinav-phi ya está trabajando en esto.

Desde el 31/10/2026.

  • #3795 de @abhinav-phi — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
scala
Área
networking

Línea de trabajo

Start with the Network[F].bind(UnixSocketAddress(...)) implementation and trace how deleteOnClose handles a failed bind. Use the provided Scala reproduction to confirm that the existing file is removed when binding raises BindException; the fix is done when a failed bind leaves the file intact while normal close behavior remains unchanged. Add or run the relevant Unix-socket binding tests once you locate the networking test suite.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Network[F].bind(UnixSocketAddress("/path/to/file")) deletes the file even when binding fails. deleteOnClose deletes the file not only when the socket is closed, but also when binding fails.

Reproduction:

//> using scala "3.9.0"
//> using dep "co.fs2::fs2-io:3.14.0"
import cats.effect.IO
import cats.effect.IOApp
import com.comcast.ip4s.UnixSocketAddress
import fs2.Stream
import fs2.io.file.Files
import fs2.io.net.Network

object App extends IOApp.Simple {
  def run: IO[Unit] =
    Files[IO].tempFile.use { path =>
      for {
        _ <- Stream
          .emit("123456")
          .through(Files[IO].writeUtf8(path))
          .compile
          .drain
        _ <- IO.println(path)
        before <- Files[IO].exists(path)
        _ <- IO.println(s"Exists before bind: $before")
        result <- Network[IO]
          .bind(UnixSocketAddress(path.toString))
          .use_
          .attempt
        _ <- IO.println(result)
        after <- Files[IO].exists(path)
        _ <- IO.println(s"Exists after failed bind: $after")
      } yield ()
    }
}
/tmp/17591615494821517556.tmp
Exists before bind: true
Left(java.net.BindException: Address in use)
Exists after failed bind: false
Lenguaje dominante
Scala
Estrellas
2.5k
Forks
633
Merge medio
3 d 21 h
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de typelevel/fs2

Todos los issues de typelevel/fs2

Issues similares

Más issues de Scala

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.