HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/node_modules/needle/test/long_string_spec.js
var needle = require('../'),
    should = require('should');

describe('when posting a very long string', function() {

  this.timeout(20000);

  function get_string(length) {
    var str = '';
    for (var i = 0; i < length; i++) {
      str += 'x';
    }
    return str;
  }

  var major_version = process.version.split('.')[0];

  it("shouldn't throw an EPIPE error out of nowhere", function(done) {

    // for some reason this test fails in Github Actions with Node v8.x
    // although in my Linux box passes without issues
    if (process.env.CI && (major_version == 'v8' || major_version == 'v6')) {
      return done();
    }

    var error;

    function finished() {
      setTimeout(function() {
        should.not.exist(error);
        done();
      }, 300);
    }

    try {
      needle.post('https://google.com', { data: get_string(Math.pow(2, 20)) }, finished)
    } catch(e) {
      error = e;
    }

  })

})