typegoose / mongodb-memory-server

Manage & spin up mongodb server binaries with zero(or slight) configuration for tests.
https://typegoose.github.io/mongodb-memory-server/
MIT License
2.58k stars 187 forks source link

Fails to follow HTTP redirects when downloading Mongo #785

Closed MattA48 closed 1 year ago

MattA48 commented 1 year ago

Versions

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 ```txt 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. (/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

hasezoey commented 1 year ago

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 commented 1 year ago

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