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

aqua cli can't handle writing to short pipes #460

Closed
folex opened this issue Mar 21, 2022 · 0 comments · Fixed by #489
Closed

aqua cli can't handle writing to short pipes #460

folex opened this issue Mar 21, 2022 · 0 comments · Fixed by #489
Assignees
Labels
bug Something isn't working cli CLI usability and bugs

Comments

@folex
Copy link
Member

folex commented Mar 21, 2022

If you pass output of the aqua to a pipe that doesn't read the whole output, aqua throws write EPIPE error.

Simple way to reproduce is to send any aqua command to head -n1, as in aqua ... | head -n1.

A real-life example is passing aqua getInterface to jq . for JSON parsing. jq detects incorrect JSON, and stops reading. Aqua complains.

Instead, it should handle writing to pipes correctly. As I understand it, if stdout/stderr is closed, simply don't write there.

This is a rather critical bug for a CLI tool, because it makes it impossible to use for automation and scripting.

 % aqua getInterface --addr /dns4/kras-00.fluence.dev/tcp/19990/wss/p2p/12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e --id nonexistent-service | jq .
parse error: Invalid numeric literal at line 1, column 5
call failed with an error `Local service error, ret_code is 1, error message is '"Error: Service with id 'nonexistent-service' not found"'`, peerId `12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e`
xor caught an error: Local service error, ret_code is 1, error message is '"Error: Service with id 'nonexistent-service' not found"'
node:events:368
      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:795:11)
    at Socket._write (node:net:807:8)
    at writeOrBuffer (node:internal/streams/writable:390:12)
    at _write (node:internal/streams/writable:331:10)
    at Socket.Writable.write (node:internal/streams/writable:335:10)
    at ReadableWorkerStdio.ondata (node:internal/streams/readable:777:22)
    at ReadableWorkerStdio.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:324:12)
Emitted 'error' event on Socket instance at:
    at Socket.onerror (node:internal/streams/readable:796:14)
    at Socket.emit (node:events:390:28)
    at emitErrorNT (node:internal/streams/destroy:164:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Node.js v17.3.0
@folex folex added bug Something isn't working cli CLI usability and bugs labels Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli CLI usability and bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants