Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

`firebase_admin.db.reference` leaks connections in a `CLOSE_WAIT` state

未關閉
#709 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
firebase, python
領域
database

研究方向

首先,使用 Python websocket 伺服器重現問題:建立一個 firebase_admin.db.reference,並在連線處理常式中呼叫 set。連線終止後使用 netstat 檢查 CLOSE_WAIT socket。完成的標準是說明 reference 連線的生命週期,並解決回報的累積問題,或記錄所需的 teardown 行為。

由索引模型根據 Issue 內容生成。

描述

api: database type: bug
Step 2: Describe your environment
  • Operating System version: OS X Ventura 13.4
  • Firebase SDK version: 6.2.0
  • Firebase Product: database
  • Python version: 3.11.2
  • Pip version: 23.1.2
Step 3: Describe the problem

I have a Python websocket application that creates a reference to RTDB via firebase_admin.db.reference, and writes to it via the set method. I create one reference per connection to my database. It appears that this reference does not necessarily get cleaned up, as I've noticed in my server that connections with a CLOSE_WAIT state are aggregating specifically with this RTDB update. More concerning is that the application appears to be receiving bytes of data at a consistent rate from this connection despite it being in a CLOSE_WAIT state.

What is the proper way to tear down a reference once I know I'm done with it? It seems like this is a bug from the firebase_admin python package as there don't be any instructions or indication that we need to tear down the reference.

Steps to reproduce:
  1. Create a Python websocket server with the websockets library
  2. Within the connection handler, instantiate a reference via firebase_admin.db.reference and write a value
  3. Approximately 1 minute after the connection terminates, use netstat to observe that the connection still exists in a CLOSE_WAIT state and that the application is receiving data from it.

Here's my netstat output

root@474683837e04:/app# netstat -ntuap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.11:38913        0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      1/python
tcp       25      0 172.24.0.3:34160        34.120.160.131:443      CLOSE_WAIT  1/python
tcp        1      0 172.24.0.3:58576        142.250.191.74:443      CLOSE_WAIT  1/python
tcp6       0      0 :::8080                 :::*                    LISTEN      1/python
udp        0      0 127.0.0.11:54888        0.0.0.0:*                           -

Using connections with all of the reference related code commented out and then netstat'ing after shows that this issue does not appeare.

主要語言
Python
星號
1.2k
分支
359
平均合併
3 天 9 小時
30 天內合併 PR
3

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

firebase/firebase-admin-python 的其他 Issue

查看 firebase/firebase-admin-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。