Skip to content

Search Example returning an Error: maximum redirect limit exceeded #53

Description

@mbmcmullen27

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: ''
  }
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions