rtfpessoa / diff2html-cli

Pretty diff to html javascript cli (diff2html-cli)
https://diff2html.xyz
MIT License
532 stars 50 forks source link

ENOBUFS error when comparing large commits #113

Closed darrenchang closed 3 years ago

darrenchang commented 3 years ago

I have a really large commit on my private repository. It contains a new json file that has over 40000 lines. When I try to compare the commit, it shows the following error.

# diff2html v1.1.5 v1.2.7

<ref *1> Error: spawnSync /bin/sh ENOBUFS
    at Object.spawnSync (internal/child_process.js:1067:20)
    at spawnSync (child_process.js:602:24)
    at Object.execSync (child_process.js:647:15)
    at Object.execute (/usr/local/lib/node_modules/diff2html-cli/lib/utils.js:38:36)
    at runGitDiff (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:87:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:125:32)
    at step (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:63:23)
    at Object.next (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:44:53)
    at /usr/local/lib/node_modules/diff2html-cli/lib/cli.js:38:71
    at new Promise (<anonymous>) {
  errno: -105,
  code: 'ENOBUFS',
  syscall: 'spawnSync /bin/sh',
  path: '/bin/sh',
  spawnargs: [ '-c', 'git diff "v1.1.5" "v1.2.7" --no-color ' ],
  error: [Circular *1],
  status: null,
  signal: 'SIGTERM',
  output: [
    null,
    <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 2e 67 69 74 69 67 6e 6f 72 65 20 62 2f 2e 67 69 74 69 67 6e 6f 72 65 0a 69 6e 64 65 78 20 66 35 35 32 37 34 63 ... 1056718 more bytes>,
    <Buffer >
  ],
  pid: 12472,
  stdout: <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 2e 67 69 74 69 67 6e 6f 72 65 20 62 2f 2e 67 69 74 69 67 6e 6f 72 65 0a 69 6e 64 65 78 20 66 35 35 32 37 34 63 ... 1056718 more bytes>,
  stderr: <Buffer >
} []

How can I increase the buffer size to complete this compare?

rtfpessoa commented 3 years ago

Hi @darrenchang,

Unfortunately seems like the option is to make diff2html handle this in a streaming way as described here https://stackoverflow.com/questions/48698234/node-js-spawn-vs-execute

In theory it should not be hard since we parse the diff line by line, but I never tried to optimize this. Also if you want to contribute the change this should be fixed in https://github.com/rtfpessoa/diff2html since this repo is just a cli wrapper around it.

Closing here since opened https://github.com/rtfpessoa/diff2html/issues/359

rtfpessoa commented 3 years ago

Hi @darrenchang,

I did a possible fix and released it in version 5.1.8-fixignorepathsusespawn.1.37dcf7e. Can you check if it is fixed and let me know?

rtfpessoa commented 3 years ago

Let me know if it is not fixed and I will re-open