Unix socket bind may delete an existing file when binding fails

オープン
#3,781 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@abhinav-phi がすでに取り組んでいます。

2026年10月31日 から。

  • #3795 @abhinav-phi による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
scala
領域
networking

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Scala
スター
2.5k
フォーク
633
平均マージ
4日 16時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

typelevel/fs2 のほかの issue

typelevel/fs2 の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。