JohnXLivingston / peertube-plugin-livechat

GNU Affero General Public License v3.0
86 stars 26 forks source link

prosodyctl stdin errors randomly in yesMode interval callback with EPIPE #416

Closed OPNA2608 closed 2 weeks ago

OPNA2608 commented 3 weeks ago

Describe the bug

While testing a packaging of this plugin, I'm randomly seeing the following on peertube startup:

[...]
server # [   68.577090] peertube[1395]: [localhost:9000 peertube-plugin-livechat] 2024-06-11 17:35:19.092 debug: ProsodyCtl was called in yesMode, writing to standard input.
server # [   68.587410] peertube[1395]: [localhost:9000 peertube-plugin-livechat] 2024-06-11 17:35:19.102 debug: ProsodyCtl was called in yesMode, writing to standard input.
server # [   68.597988] peertube[1395]: [localhost:9000 peertube-plugin-livechat] 2024-06-11 17:35:19.113 debug: ProsodyCtl was called in yesMode, writing to standard input.
server # [   68.610103] peertube[1395]: [localhost:9000] 2024-06-11 17:35:19.124 error: uncaughtException: write EPIPE
server # [   68.611366] peertube[1395]: Error: write EPIPE
server # [   68.611937] peertube[1395]:     at afterWriteDispatched (node:internal/stream_base_commons:160:15)
server # [   68.612984] peertube[1395]:     at writeGeneric (node:internal/stream_base_commons:151:3)
server # [   68.613948] peertube[1395]:     at Socket._writeGeneric (node:net:962:11)
server # [   68.614769] peertube[1395]:     at Socket._write (node:net:974:8)
server # [   68.615932] peertube[1395]:     at writeOrBuffer (node:internal/streams/writable:392:12)
server # [   68.617147] peertube[1395]:     at _write (node:internal/streams/writable:333:10)
server # [   68.617993] peertube[1395]:     at Writable.write (node:internal/streams/writable:337:10)
server # [   68.619690] peertube[1395]:     at Timeout._onTimeout (/nix/store/n0hwv6vkif6f054hiqzmcp999sy1vxgs-peertube-plugin-livechat-10.0.2/lib/node_modules/peertube-plugin-livechat/dist/server/lib/prosody/ctl.js:131:31)
server # [   68.621667] peertube[1395]:     at listOnTimeout (node:internal/timers:569:17)
server # [   68.623159] peertube[1395]:     at process.processTimers (node:internal/timers:512:7)

My understanding of this situation is that a call of the interval callback happens at an inopportune time while the prosodyctl process' stdin is done but the interval callback hasn't been deregistered yet?

To Reproduce Steps to reproduce the behavior:

  1. Get Nix
  2. Clone https://github.com/ngi-nix/ngipkgs/tree/init/peertube-plugins/livechat
  3. Comment out this line to remove a workaround for this
  4. Run nix --extra-experimental-features "nix-command flakes" build .#nixosTests.Peertube.peertube-plugins, check for the above error near the end
  5. If it hasn't happened, re-run step 4 with --rebuild afew times

Expected behavior The exception should be caught, or whatever situation is causing the exception should be handled.

Screenshots n/a

Server (please complete the following information):

Plugin diagnostic: (I don't know where this is yet)

Desktop (please complete the following information): Not relevant

Smartphone (please complete the following information): Not relevant

Additional context

Here is a full VM test log, the issue happens near the end: x8si5q5nj4p6ibra7j1hyna5n821x6m1-vm-test-run-peertube-plugins.log

Submitting the vendored patch as a suggestion in abit, the PR template asks for an issue to be made first.

JohnXLivingston commented 2 weeks ago

Good catch. Thanks.

PS: Do you want to appear in the SPDX-FileCopyrightText header? If yes, which nickname, and which email or website?

OPNA2608 commented 2 weeks ago

Sure, please take the details from my git commit's From: section: https://github.com/JohnXLivingston/peertube-plugin-livechat/commit/ad27a76fab884ae1d939aee094ec7414ee174ab7.patch

JohnXLivingston commented 2 weeks ago

Sure, please take the details from my git commit's From: section: https://github.com/JohnXLivingston/peertube-plugin-livechat/commit/ad27a76fab884ae1d939aee094ec7414ee174ab7.patch

Done.

JohnXLivingston commented 1 week ago

@OPNA2608 , new plugin version (10.1.0) is released, including your fix.