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

RequestError: unexpected end of file #1826

Closed
2 tasks done
TKul6 opened this issue Aug 8, 2021 · 7 comments
Closed
2 tasks done

RequestError: unexpected end of file #1826

TKul6 opened this issue Aug 8, 2021 · 7 comments

Comments

@TKul6
Copy link

TKul6 commented Aug 8, 2021

Describe the bug

  • Node.js version: 14
  • OS & version: Linux

Actual behavior

When I execute number of requests one after the other, after X request (the number is changes after each running) I get the following error from got: RequestError: unexpected end of file at PassThrough.eval (webpack://justeat/./node_modules/got/dist/source/core/index.js?:800:31)
The status code is 200 and the status is OK.
...

Expected behavior

To parse the response successfully.
...

Code to reproduce

let options = {
    url: "<ANY_URL>",
    return_full_response: true,
    resolve_with_full_response: true,
    timeout: 120000,
    retries: 1,
    responseType: "text",
    throwHttpErrors: false,
    agent: {
      https: tunnel.httpsOverHttp({
        rejectUnauthorized: false,
        proxy: {
          host: "<PROXY_IP>",
          port: <PROXY_PORT>
        }
      })
    }
  };
  for (let attempt_number = 0; attempt_number < 100; attempt_number++) {
    console.log(`Fetching attempt number ${attempt_number}.`);
    const res = await got(options);
    console.log(res.statusCode);
  }

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
@szmarczak
Copy link
Collaborator

Please post the full stack trace.

@TKul6
Copy link
Author

TKul6 commented Aug 9, 2021

Thanks @szmarczak, here is the full stack:

    at PassThrough.eval (webpack://justeat/./node_modules/got/dist/source/core/index.js?:800:31)
    at Object.onceWrapper (events.js:482:26)
    at PassThrough.emit (events.js:387:35)
    at PassThrough.emit (domain.js:470:12)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
    at Zlib.zlibOnError [as onerror] (zlib.js:188:17)```

@szmarczak
Copy link
Collaborator

Duplicate of #224 but this shouldn't happen.

@szmarczak szmarczak added bug Something does not work as it should ✭ help wanted ✭ labels Aug 9, 2021
@szmarczak
Copy link
Collaborator

Can you provide a fully working code to reproduce?

@TKul6
Copy link
Author

TKul6 commented Aug 9, 2021

Sure, @szmarczak here you go:

const tunnel = require("tunnel");

async function work() {
  console.log("testing");
  let options = {
    url: <ANY_LINK>,
    return_full_response: true,
    resolve_with_full_response: true,
    timeout: 120000,
    retries: 1,
    responseType: "text",
    throwHttpErrors: false,
    agent: {
      https: tunnel.httpsOverHttp({
        rejectUnauthorized: false,
        proxy: {
          host: <PROXY_IP>,
          port: <PROXY_PORT>
        }
      })
    }
  };
  for (let attempt_number = 0; attempt_number < 100; attempt_number++) {
    console.log(`Fetching attempt number ${attempt_number}.`);
    const res = await got(options);
    console.log(res.statusCode);
  }
}

work();

@szmarczak
Copy link
Collaborator

I ran locally (with a proxy) and no bugs on main branch
import got from './dist/source/index.js';
import tunnel from 'tunnel';

async function work() {
  console.log("testing");
  let options = {
    url: 'https://httpbin.org/anything',
    // return_full_response: true,
    // resolve_with_full_response: true,
    timeout: 120000,
    retry: {limit: 1},
    responseType: "text",
    throwHttpErrors: false,
    agent: {
      https: tunnel.httpsOverHttp({
        rejectUnauthorized: false,
        proxy: {
          host: '127.0.0.1',
          port: 8001,
		  proxyAuth: 'username:password'
        }
      })
    }
  };
  for (let attempt_number = 0; attempt_number < 100; attempt_number++) {
    console.log(`Fetching attempt number ${attempt_number}.`);
    const res = await got(options);
    console.log(res.statusCode);
  }
}

work();
testing
Fetching attempt number 0.
200
Fetching attempt number 1.
200
Fetching attempt number 2.
200
Fetching attempt number 3.
200
Fetching attempt number 4.
200
Fetching attempt number 5.
200
Fetching attempt number 6.
200
Fetching attempt number 7.
200
Fetching attempt number 8.
200
Fetching attempt number 9.
200
Fetching attempt number 10.
200
Fetching attempt number 11.
200
Fetching attempt number 12.
200
Fetching attempt number 13.
200
Fetching attempt number 14.
200
Fetching attempt number 15.
200
Fetching attempt number 16.
200
Fetching attempt number 17.
200
Fetching attempt number 18.
200
Fetching attempt number 19.
200
Fetching attempt number 20.
200
Fetching attempt number 21.
200
Fetching attempt number 22.
200
Fetching attempt number 23.
200
Fetching attempt number 24.
200
Fetching attempt number 25.
200
Fetching attempt number 26.
200
Fetching attempt number 27.
200
Fetching attempt number 28.
200
Fetching attempt number 29.
200
Fetching attempt number 30.
200
Fetching attempt number 31.
200
Fetching attempt number 32.
200
Fetching attempt number 33.
200
Fetching attempt number 34.
200
Fetching attempt number 35.
200
Fetching attempt number 36.
200
Fetching attempt number 37.
200
Fetching attempt number 38.
200
Fetching attempt number 39.
200
Fetching attempt number 40.
200
Fetching attempt number 41.
200
Fetching attempt number 42.
200
Fetching attempt number 43.
200
Fetching attempt number 44.
200
Fetching attempt number 45.
200
Fetching attempt number 46.
200
Fetching attempt number 47.
200
Fetching attempt number 48.
200
Fetching attempt number 49.
200
Fetching attempt number 50.
200
Fetching attempt number 51.
200
Fetching attempt number 52.
200
Fetching attempt number 53.
200
Fetching attempt number 54.
200
Fetching attempt number 55.
200
Fetching attempt number 56.
200
Fetching attempt number 57.
200
Fetching attempt number 58.
200
Fetching attempt number 59.
200
Fetching attempt number 60.
200
Fetching attempt number 61.
200
Fetching attempt number 62.
200
Fetching attempt number 63.
200
Fetching attempt number 64.
200
Fetching attempt number 65.
200
Fetching attempt number 66.
200
Fetching attempt number 67.
200
Fetching attempt number 68.
200
Fetching attempt number 69.
200
Fetching attempt number 70.
200
Fetching attempt number 71.
200
Fetching attempt number 72.
200
Fetching attempt number 73.
200
Fetching attempt number 74.
200
Fetching attempt number 75.
200
Fetching attempt number 76.
200
Fetching attempt number 77.
200
Fetching attempt number 78.
200
Fetching attempt number 79.
200
Fetching attempt number 80.
200
Fetching attempt number 81.
200
Fetching attempt number 82.
200
Fetching attempt number 83.
200
Fetching attempt number 84.
200
Fetching attempt number 85.
200
Fetching attempt number 86.
200
Fetching attempt number 87.
200
Fetching attempt number 88.
200
Fetching attempt number 89.
200
Fetching attempt number 90.
200
Fetching attempt number 91.
200
Fetching attempt number 92.
200
Fetching attempt number 93.
200
Fetching attempt number 94.
200
Fetching attempt number 95.
200
Fetching attempt number 96.
200
Fetching attempt number 97.
200
Fetching attempt number 98.
200
Fetching attempt number 99.
200

@szmarczak
Copy link
Collaborator

I tested again with got@11.8.2 and no issues as well.

@szmarczak szmarczak removed bug Something does not work as it should ✭ help wanted ✭ labels Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants