restify / node-restify

The future of Node.js REST development
http://restify.com
MIT License
10.71k stars 981 forks source link

avoid loading spdy if not used and prevent deprecation warning #1943

Closed massimocandela closed 1 year ago

massimocandela commented 1 year ago

First of all, thanks for the great Restify!! I've been using it for years in several projects (including this).

Pre-Submission Checklist

Issues

Closes:

Support for Node14 will end in 2 months, we need to move to Node 16+. However, restify imports spdy, which raises

DeprecationWarning: Access to process.binding('http_parser') is deprecated.

The good news is that most of the time spdy is not used since you need to pass options.spdy.

Changes

We can simply avoid deprecation warnings (and also avoid to run unused code) by importing spdy on request (as currently done for http2). This could be both a permanent or temporary solution waiting for spdy to be patched.

acommodari commented 1 year ago

Would love for this to get merged 🙏 Getting rid of this deprecation warning would be a godsend

NormandoHall commented 1 year ago

So, when you release it?

jalopez commented 1 year ago

Is there any chance this PR will be included in the next release?

tokidoki11 commented 3 months ago

I wonder if this pr is in any of releases so far?

NormandoHall commented 3 months ago

Restify is dead. Migrate to express

XVincentX commented 1 month ago

I was having the same problem and fixed it by using patch-package with the following content on Restify 1.11:

diff --git a/node_modules/restify/lib/server.js b/node_modules/restify/lib/server.js
index a586532..412e850 100644
--- a/node_modules/restify/lib/server.js
+++ b/node_modules/restify/lib/server.js
@@ -11,7 +11,6 @@ var _ = require('lodash');
 var assert = require('assert-plus');
 var errors = require('restify-errors');
 var mime = require('mime');
-var spdy = require('spdy');
 var vasync = require('vasync');

 var Chain = require('./chain');
@@ -187,6 +186,7 @@ function Server(options) {
     ];

     if (options.spdy) {
+        var spdy = require('spdy');
         this.spdy = true;
         this.server = spdy.createServer(options.spdy);
     } else if (options.http2) {