antonmedv/fx

Wordy transformations cause `fx` to crash with piped data

Opened this issue · 3 comments

fx tries to open the first argument as a file even when the JSON data comes from stdin. This causes it to crash when a single transformation command is too long.

On my ext4 system, this:

echo "{}" | fx "x => {
    const thisVariableNameEatsUpPreciousCharacters = {
        hereAreMoreCharacters: '💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀'
    };

    return {...x, ...thisVariableNameEatsUpPreciousCharacters};
}"

crashes with this:

error: Uncaught (in promise) Error: ENAMETOOLONG: name too long, stat
  const stat = fs.statSync(path, {throwIfNoEntry: false})
                  ^
    at __node_internal_captureLargerStackTrace (ext:deno_node/internal/errors.ts:91:9)
    at __node_internal_uvException (ext:deno_node/internal/errors.ts:184:10)
    at denoErrorToNodeError (ext:deno_node/internal/errors.ts:1871:14)
    at Module.statSync (ext:deno_node/_fs/_fs_stat.ts:166:13)
    at isFile (file:///tmp/fx-34.0.0.js:275:19)
    at main (file:///tmp/fx-34.0.0.js:35:7)

I guess it can usually be worked around by splitting the commands up into multiple arguments, but it's still annoying.

This is a bug. Fx should check if file exists first.

On macos it works:

image

Got the error:

}'
    at Module.statSync (node:fs:1659:25)
    at isFile (/private/var/folders/2j/0x_1mj9j4tz5hzqghjckptj80000gn/T/fx-34.0.0.js:275:19)
    at main (/private/var/folders/2j/0x_1mj9j4tz5hzqghjckptj80000gn/T/fx-34.0.0.js:35:7) {
  errno: -63,
  code: 'ENAMETOOLONG',
  syscall: 'stat',
  path: 'x => {\n' +
    '    const thisVariableNameEatsUpPreciousCharacters = {\n' +
    "        hereAreMoreCharacters: '💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀dsasdfaskjdfhaskldjfhgaslkdjfhasdlkfjhasdlkfjhasdlfkjhasdflkjasdhflkjasdhflacnskdcfhalsdkfjhasldkfjhcasdlckfajhdsflbkasjdhfclnaskdjhfalskdfgjhsdflkfjhasdlfkahjsdflkasjhdflkafdggrhdfggsdfghsdghadfgsdfgsdfglhadshfglaksjdfhalskjdfhasldkfjhaldfkjhasdlfkjhasdflkjhadflkhasdlkfjhdfkhjasdlfkjhasdflkhaflkcansdfhvlkvajhfgvbalergtcqwaleifhavslbkfchasdblkfhldsfhasdfasfasdfdfdddddddadlakfjhas;dlkfa💀'\n" +