[Audio/Lavalink] ValueError: I/O operation on closed pipe when shutdown/restart while using default Java executable (solution inside) #6523

Closed
opened 2025-02-08 04:26:59 +01:00 by mario31274 · 2 comments
mario31274 commented 2025-02-08 04:26:59 +01:00 (Migrated from github.com)

What Red version are you using?

3.5.16

What were you trying to do?

Shutdown the bot to update from 3.5.15 to 3.5.16

What did you expect to happen?

Shutdown peacefully and then restart the bot and Lavalink

What actually happened?

It occurred to me that one of my RedBot instances was raising error at asyncio:

Traceback (most recent call last):
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 126, in __del__
    self.close()
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 104, in close
    proto.pipe.close()
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 758, in call_soon
    self._check_closed()
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000018F1C2623E0>
Traceback (most recent call last):
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 115, in __del__
    _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 79, in __repr__
    info.append(f'fd={self._sock.fileno()}')
                      ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_utils.py", line 102, in fileno
    raise ValueError("I/O operation on closed pipe")
ValueError: I/O operation on closed pipe

which failed to terminate java.exe and blocked the port, making it impossible to restart Lavalink.

How can we reproduce this error?

  1. !llset java to set to the default java executable. The default executable for me was C:\Program Files\Common Files\Oracle\Java\javapath\java.EXE
  2. !shutdown or !restart
  3. ValueError will occur

Anything else?

Temporary solution: Change your Java executable to Java 11.

This error did not happen on the instance that uses a different Java executable (jdk-11.0.16). No error occurred when shutting down/restarting while using this version of java.exe. I lost an hour and a half because I thought the problem was the port or the Lavalink.exe.

### What Red version are you using? 3.5.16 ### What were you trying to do? Shutdown the bot to update from 3.5.15 to 3.5.16 ### What did you expect to happen? Shutdown peacefully and then restart the bot and Lavalink ### What actually happened? It occurred to me that one of my RedBot instances was raising error at asyncio: ```Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x0000018F1C260C20> Traceback (most recent call last): File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 126, in __del__ self.close() File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_subprocess.py", line 104, in close proto.pipe.close() File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 108, in close self._loop.call_soon(self._call_connection_lost, None) File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 758, in call_soon self._check_closed() File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 519, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x0000018F1C2623E0> Traceback (most recent call last): File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 115, in __del__ _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 79, in __repr__ info.append(f'fd={self._sock.fileno()}') ^^^^^^^^^^^^^^^^^^^ File "C:\Users\*****\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_utils.py", line 102, in fileno raise ValueError("I/O operation on closed pipe") ValueError: I/O operation on closed pipe ``` which failed to terminate java.exe and blocked the port, making it impossible to restart Lavalink. ### How can we reproduce this error? 1. `!llset java` to set to the default java executable. The default executable for me was `C:\Program Files\Common Files\Oracle\Java\javapath\java.EXE` 2. `!shutdown` or `!restart` 3. ValueError will occur ### Anything else? Temporary solution: Change your Java executable to Java 11. This error did not happen on the instance that uses a different Java executable (jdk-11.0.16). No error occurred when shutting down/restarting while using this version of java.exe. I lost an hour and a half because I thought the problem was the port or the Lavalink.exe.
Owner

Analyse: C:\Program Files\Common Files\Oracle\Java\javapath\java.exe ist kein echtes Java, sondern ein Starter von Oracle, der die eigentliche java.exe als Kindprozess startet. Audio beendet beim Shutdown nur den Starter (terminate()), das echte Java läuft weiter und blockiert den Port. Workaround: Mit [p]llset java direkt auf die java.exe im JDK-Ordner zeigen (z. B. C:\Program Files\Eclipse Adoptium\jdk-17...\bin\java.exe). Ein richtiger Fix wäre, unter Windows den ganzen Prozessbaum zu beenden oder den javapath-Starter beim Setzen zu erkennen. Das kann ich hier nicht unter Windows testen, deshalb bleibt das Issue offen.


Generated by Claude Code

Analyse: `C:\Program Files\Common Files\Oracle\Java\javapath\java.exe` ist kein echtes Java, sondern ein Starter von Oracle, der die eigentliche `java.exe` als Kindprozess startet. Audio beendet beim Shutdown nur den Starter (`terminate()`), das echte Java läuft weiter und blockiert den Port. Workaround: Mit `[p]llset java` direkt auf die `java.exe` im JDK-Ordner zeigen (z. B. `C:\Program Files\Eclipse Adoptium\jdk-17...\bin\java.exe`). Ein richtiger Fix wäre, unter Windows den ganzen Prozessbaum zu beenden oder den javapath-Starter beim Setzen zu erkennen. Das kann ich hier nicht unter Windows testen, deshalb bleibt das Issue offen. --- _Generated by [Claude Code](https://claude.ai/code)_
Owner

Erledigt in c73e0b1c9. Behoben: Unter Windows beendet Audio den Lavalink-Prozess jetzt samt Prozessbaum (taskkill /T /F). Auch beim Oracle-Starter javapath\java.exe läuft danach kein Java-Prozess mehr weiter, der den Port blockiert. Unter Linux und macOS bleibt es bei terminate().


Generated by Claude Code

Erledigt in c73e0b1c9. Behoben: Unter Windows beendet Audio den Lavalink-Prozess jetzt samt Prozessbaum (`taskkill /T /F`). Auch beim Oracle-Starter `javapath\java.exe` läuft danach kein Java-Prozess mehr weiter, der den Port blockiert. Unter Linux und macOS bleibt es bei `terminate()`. --- _Generated by [Claude Code](https://claude.ai/code)_
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot#6523
No description provided.