node-craigslist icon indicating copy to clipboard operation
node-craigslist copied to clipboard

Search Example returning an Error: maximum redirect limit exceeded

Open mbmcmullen27 opened this issue 3 years ago • 5 comments

Running the #search example in the README returns an error for too many redirects. Tried adjusting the city and the search query but the redirect limit error is always returned.

reproduced in node versions: v15.12.0 v14.16.0

var
  craigslist = require('node-craigslist'),
  client = new craigslist.Client({
    city : 'seattle'
  });

client
  .search('xbox one')
  .then((listings) => {
    // play with listings here...
    listings.forEach((listing) => console.log(listing));
  })
  .catch((err) => {
    console.error(err);
  });

throws:

Error: maximum redirect limit exceeded
    at ClientRequest.<anonymous> (/mnt/c/Users/mbmcm/example/node_modules/reqlib/dist/index.js:429:29)
    at Object.onceWrapper (node:events:476:26)
    at ClientRequest.emit (node:events:369:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:636:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:129:17)
    at Socket.socketOnData (node:_http_client:502:22)
    at Socket.emit (node:events:369:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9)
    at Socket.Readable.push (node:internal/streams/readable:227:10) {
  options: {
    hostname: 'seattle.craigslist.org',
    method: 'GET',
    path: '/',
    maxRedirectCount: 5,
    maxRetryCount: 3,
    timeout: 60000,
    headers: { 'Content-Type': 'application/json', 'Content-Length': 0 },
    [Symbol(context)]: URLContext {
      flags: 400,
      scheme: 'https:',
      username: '',
      password: '',
      host: 'seattle.craigslist.org',
      port: null,
      path: [Array],
      query: null,
      fragment: null
    },
    [Symbol(query)]: URLSearchParams {}
  },
  state: {
    data: '',
    failover: { index: 0, values: [] },
    redirects: [ [URL], [URL], [URL], [URL], [URL] ],
    tries: 1,
    headers: { location: 'https://seattle.craigslist.org/' },
    statusCode: 301
  }
}

the redirects:

[
  URL {
    href: 'https://seattle.craigslist.org/search/sss?sort=rel&query=xbox%20one',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/search/sss',
    search: '?sort=rel&query=xbox%20one',
    searchParams: URLSearchParams { 'sort' => 'rel', 'query' => 'xbox one' },
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  }
]

mbmcmullen27 avatar Mar 30 '21 23:03 mbmcmullen27

I am getting the same result as well on node v16.0.0

eajr avatar Apr 28 '21 02:04 eajr

I am having the same issue. Please resolve this

amirmursal avatar May 09 '21 04:05 amirmursal

Can confirm.

3h50 avatar Aug 14 '21 14:08 3h50

I am also running into this.

dylan-albertazzi avatar Aug 20 '21 21:08 dylan-albertazzi

I'm also hitting this problem.

pcbailey avatar Feb 03 '22 19:02 pcbailey