bitpay / bitcore

A full stack for bitcoin and blockchain-based applications
https://bitcore.io/
MIT License
4.84k stars 2.09k forks source link

V8 DeprecationWarning UrlParser #1658

Closed osagga closed 6 years ago

osagga commented 6 years ago

When running a clean install of bitcore v8, the log shows the following warning

(node:23459) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

I'm using the required node version

$ node -v
v8.9.4
micahriggan commented 6 years ago

This has to do with the mongo version change, should be an easy fix

osagga commented 6 years ago

So I tried adding useNewUrlParser to the connect call as follows:

return MongoClient.connect(
          connectUrl,
          {
            keepAlive: 1,
            poolSize: config.maxPoolSize,
            useNewUrlParser: true
            /*
             *nativeParser: true
             */
          }
        );

But it throws this runtime error

src/services/storage.ts(36,13): error TS2345: Argument of type '{ keepAlive: number; poolSize: number; useNewUrlParser: boolean; }' is not assignable to parameter of type 'MongoClientOptions | undefined'.
  Object literal may only specify known properties, and 'useNewUrlParser' does not exist in type 'MongoClientOptions | undefined'.

I'm not really sure if there's a problem with the mongodb package or something else?

micahriggan commented 6 years ago

That's a typings error, try updating package.json to have @types/mongodb: 3.1.3,

May fix it, I'm checking now

micahriggan commented 6 years ago

That MR should fix at least the mongo error. Will test the generate blocks issue with this await change and see if it affects it.

osagga commented 6 years ago

I'll test it out and keep you updated, thanks!