Unix socket bind may delete an existing file when binding fails

Aperta
#3,781 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@abhinav-phi ci sta già lavorando.

Dal 31/10/2026.

  • #3795 di @abhinav-phi — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
scala
Ambito
networking

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Scala
Stelle
2.5k
Fork
633
Merge medio
4g 16h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di typelevel/fs2

Tutte le issue di typelevel/fs2

Issue simili

Altre issue su Scala

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.