Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xo-cli does not handle broken pipe on write #6680

Closed
borivoj-tydlitat opened this issue Feb 22, 2023 · 2 comments
Closed

xo-cli does not handle broken pipe on write #6680

borivoj-tydlitat opened this issue Feb 22, 2023 · 2 comments

Comments

@borivoj-tydlitat
Copy link

  1. ⚠️ If you don't follow this template, the issue will be closed.
  2. ⚠️ If your issue can't be easily reproduced, please report it on the forum first.

Are you using XOA or XO from the sources? sources

If XOA:

If XO from the sources:

Describe the bug

xo-cli utility does not handle broken pipe on output (write() returning EPIPE) gracefully, printing an error message with a stack trace to stderr.
Example:

$ xo-cli --list-objects type=VM  | head
[
{
  "type": "VM",
  "addresses": {
    "0/ipv4/0": "*******",
    "0/ipv6/0": "*******"
  },
  "affinityHost": "09798493-856c-470b-81b6-1b46f30ed7f9",
  "auto_poweron": true,
  "bios_strings": {
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (node:internal/stream_base_commons:160:15)
    at writeGeneric (node:internal/stream_base_commons:151:3)
    at Socket._writeGeneric (node:net:917:11)
    at Socket._write (node:net:929:8)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Object.listObjects (file:///home/tydlitat/mama/ghe/ext/xen-orchestra/packages/xo-cli/index.mjs:414:14)
    at async main (file:///home/tydlitat/mama/ghe/ext/xen-orchestra/packages/xo-cli/index.mjs:282:14)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v18.12.1

To Reproduce
Steps to reproduce the behavior:
Pipe the output of xo-cli into any process that will close the pipe early.
Exaple as above: xo-cli --list-objects type=VM | head

Expected behavior
xo-cli terminating gracefully on broken pipe, with no error logged.

Screenshots
n/a

Environment (please provide the following information):

  • Node: 18.12.1
  • hypervisor: XCP-ng 8.2.1

Additional context
Reproduced on Fedora FC37.

@julien-f
Copy link
Member

It should be fixed, please test and confirm 🙂

@borivoj-tydlitat
Copy link
Author

Yes, the fix works. Thank you!

MathieuRA pushed a commit that referenced this issue Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants