Sylwester Lachiewicz created THRIFT-6203:
--------------------------------------------

             Summary: Node.js library uses url.parse(), fs.exists() and 
require("constants"), all deprecated
                 Key: THRIFT-6203
                 URL: https://issues.apache.org/jira/browse/THRIFT-6203
             Project: Thrift
          Issue Type: Improvement
          Components: Node.js - Library
            Reporter: Sylwester Lachiewicz


The Node.js library calls three APIs that Node has deprecated, so an 
application embedding it prints deprecation warnings on every supported runtime.

|| API || Notice || Call site ||
| {{url.parse()}} | DEP0169 | 
[lib/nodejs/lib/thrift/web_server.js|https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/web_server.js],
 in {{processPost}} and {{processGet}} |
| {{fs.exists()}} | DEP0006 | 
[lib/nodejs/lib/thrift/web_server.js|https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/web_server.js]
 |
| {{require("constants")}} | DEP0063 | 
[lib/nodejs/lib/thrift/server.js|https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/server.js],
 
[lib/nodejs/lib/thrift/connection.js|https://github.com/apache/thrift/blob/master/lib/nodejs/lib/thrift/connection.js]
 |

The replacements are the WHATWG {{URL}} class, {{fs.stat()}} and 
{{require("crypto").constants}}.

Moving to the WHATWG parser changes one behaviour worth stating: 
{{url.parse()}} accepts a malformed request target and {{new URL()}} throws on 
one, so the server answers 400 where it previously carried on with a 
partly-parsed path.

h3. Unset options.services

Separately, {{createWebServer}} reads {{options.services}} without a default. A 
server configured to serve only static files has no reason to pass it, and the 
first POST then fails:

{noformat}
TypeError: Cannot read properties of undefined (reading '/')
{noformat}

The registration loop does not catch this, because {{for...in}} over 
{{undefined}} is a no-op rather than an error, so the misconfiguration only 
surfaces on a request rather than at construction.

Submitted as [PR #3821|https://github.com/apache/thrift/pull/3821].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to