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

Fails to follow HTTP redirects when downloading Mongo #785

Closed
MattA48 opened this issue Aug 2, 2023 · 2 comments · Fixed by #786 · 4 remaining pull requests
Closed

Fails to follow HTTP redirects when downloading Mongo #785

MattA48 opened this issue Aug 2, 2023 · 2 comments · Fixed by #786 · 4 remaining pull requests

Comments

@MattA48
Copy link

MattA48 commented Aug 2, 2023

Versions

  • NodeJS: Docker image node:18-buster
  • mongodb-memory-server-*: 8.13.0
  • mongodb(the binary version): 5.0.14
  • mongodb(the js package): 0.0.0
  • system: Docker - (Debian Buster)
    package: mongo-memory-server

What is the Problem?

When running tests, the attempted download of Mongo fails with
DownloadError: Download failed for url "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.18.tgz", Details: Status Code isnt 200! (it is 302)

Trying to follow the link in Chrome, there is indeed a 302 redirect with message 'moved temporarily'

Code Example

Any simple script that requires mms to download a new Mongo

Debug Output

Debug Output
      Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:
       DownloadError: Download failed for url "https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.18.tgz", Details:
      Status Code isnt 200! (it is 302)
          at ClientRequest.<anonymous> (/Users/allwoodm/git_repos/IDDNToMongo/node_modules/mongodb-memory-server-core/src/util/MongoBinaryDownload.ts:433:15)
          at Object.onceWrapper (events.js:482:26)
          at ClientRequest.emit (events.js:375:28)
          at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
          at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
          at TLSSocket.socketOnData (_http_client.js:515:22)
          at TLSSocket.emit (events.js:375:28)
          at addChunk (internal/streams/readable.js:290:12)
          at readableAddChunk (internal/streams/readable.js:265:9)
          at TLSSocket.Readable.push (internal/streams/readable.js:204:10) {
        url: 'https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.18.tgz',
        msg: 'Status Code isnt 200! (it is 302)'
      }

fastdl have a temporary redirect and the downloader isn't configured to respect this

@MattA48 MattA48 added the bug label Aug 2, 2023
@hasezoey
Copy link
Member

hasezoey commented Aug 2, 2023

true, the current implementation is not made to handle redirects, only direct urls.

from my quick look, the url provided https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-5.0.18.tgz resolves 200 and not 302

i dont think this will be changed anytime soon

@hasezoey hasezoey added enhancement and removed bug labels Aug 2, 2023
MattA48 pushed a commit to MattA48/mongodb-memory-server that referenced this issue Aug 2, 2023
Add follow-redirects library to handle 302 redirects on fastdl.mongodb.org

re: typegoose#785
@hasezoey hasezoey linked a pull request Oct 5, 2023 that will close this issue
@hasezoey
Copy link
Member

hasezoey commented Oct 5, 2023

i dont know why this was not properly tagged, but follow-redirects has been added and is in use, it will follow up to 2 redirects by default

added via #786, released since 8.14.0

@hasezoey hasezoey closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment