Skip to content

Commit 45af647

Browse files
committed
add http_parser polyfill
1 parent 0c1cdce commit 45af647

File tree

3 files changed

+332
-300
lines changed

3 files changed

+332
-300
lines changed

app.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1+
/* eslint-disable global-require */
12
'use strict';
23

4+
/*
5+
* FIXME: Restify depends on `spdy`, which in turn depends on `http-deceiver`,
6+
* which uses the legacy C library `http_parser`.
7+
*
8+
* Newer versions of Node.js have removed `http_parser` in favor of
9+
* modern APIs. Unfortunately:
10+
* - `http-deceiver` was last updated ~9 years ago,
11+
* - `spdy` ~5 years ago,
12+
* - Restify itself ~2 years ago.
13+
*
14+
* As a result, these outdated libraries haven’t been replaced.
15+
*
16+
* Quick fix: polyfill `http_parser`.
17+
* Possible Long-term fix: fork Restify and remove/replace the outdated deps.
18+
*/
19+
const originalBinding = process.binding;
20+
process.binding = function (name) {
21+
if (name === 'http_parser') {
22+
return require('http-parser-js');
23+
}
24+
return originalBinding.call(process, name);
25+
};
26+
327
// Main application file
428
// Run as 'node app.js' to start
529
const path = require('path');

0 commit comments

Comments
 (0)