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

DeprecationWarning when piping to createWriteStream #10

Closed
thany opened this issue Jun 1, 2017 · 3 comments
Closed

DeprecationWarning when piping to createWriteStream #10

thany opened this issue Jun 1, 2017 · 3 comments

Comments

@thany
Copy link

thany commented Jun 1, 2017

I'm using the recommended? way to stream a request to a file, and use await to wait until I can move to downloading the next file in my queue.

const r = request(file.url);
r.pipe(fs.createWriteStream(file.target));
await r;

Simple enough. And it absolutely completely works. But, occasionally I get a warning:

DeprecationWarning: Calling an asynchronous function without callback is deprecated

Does it need a callback then? And where, what should I put into it?

Also, I'm a noob on node (expert on general javascript though) so I might not be doing it correctly. If that's the case, please do show me a correct(er) way to "just" download a binary file and wait for it.

I'm on NodeJS 7.10 and Windows 10, if that helps.

@analog-nico
Copy link
Member

Please do not use request-promise-native for streaming the response. Use request directly.

See the request-promise README for a little more detail where it says that “STREAMING THE RESPONSE (e.g. .pipe(...)) is DISCOURAGED”.

You can use request-promise-native and request alongside in your project. Depending on what kind of request you do you can just use one or the other.

@thany
Copy link
Author

thany commented Jun 5, 2017

Seems wasteful to install two components that do exactly the same. Can't this issue just be fixed?

@analog-nico
Copy link
Member

Of course. Stay tuned for the fix of the issue over on request-promise.

Btw while you wait: Technically you are already installing request. request-promise-native is just an extension that adds promise capabilities to request. request is always the library that does the actual heavy lifting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants