Skip to content

Commit

Permalink
fix: 使用补丁修改 httpolyglot
Browse files Browse the repository at this point in the history
  • Loading branch information
wll8 committed Oct 1, 2024
1 parent 401a571 commit 7288108
Show file tree
Hide file tree
Showing 4 changed files with 1,169 additions and 680 deletions.
1 change: 1 addition & 0 deletions release/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gulp.task(`copyServer`, (cb) => { // 复制 server 中的文件, 例如 package.
npx shx cp -r ../server/page ../server/util ../dist/package/
npx shx cp -r ../server/example ../dist/package/
npx shx cp -r ../server/@types ../dist/package/
npx shx cp -r ../server/patches ../dist/package/
npx shx cp ../README.md ../dist/package/
npx shx rm -f ../dist/package/*-lock.*
npx shx rm -f ../dist/package/yarn.lock
Expand Down
14 changes: 3 additions & 11 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"mime": "^3.0.0",
"morgan": "^1.10.0",
"node-http-proxy-json": "^0.1.9",
"patch-package": "^8.0.0",
"path-to-regexp": "0.1.7",
"postinstall-postinstall": "^2.1.0",
"vm2": "^3.9.12",
"whatnpm": "^1.0.0"
},
Expand All @@ -60,6 +62,7 @@
"ngrok": "^4.2.2"
},
"scripts": {
"postinstall": "patch-package",
"lint": "eslint --ignore-path ../.gitignore .",
"dts": "npx shx mkdir -p ./node_modules/mockm & npx shx cp -r ./@types ./node_modules/mockm/",
"dev": "nodemon --ignore page/ -q -w \"*.js\" --exec \"node run.js --config=.dev.mm.config.js --log-line\"",
Expand All @@ -75,17 +78,6 @@
"darwin",
"linux"
],
"resolutions": {
"express": "4.19.2"
},
"overrides": {
"express": "4.19.2"
},
"pnpm": {
"overrides": {
"express": "4.19.2"
}
},
"homepage": "https://hongqiye.com/doc/mockm/",
"keywords": [
"JSON",
Expand Down
19 changes: 19 additions & 0 deletions server/patches/@httptoolkit+httpolyglot+2.2.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/node_modules/@httptoolkit/httpolyglot/dist/index.js b/node_modules/@httptoolkit/httpolyglot/dist/index.js
index 935ac1b..ca44fbf 100644
--- a/node_modules/@httptoolkit/httpolyglot/dist/index.js
+++ b/node_modules/@httptoolkit/httpolyglot/dist/index.js
@@ -31,12 +31,9 @@ class Server extends net.Server {
tlsConfig = configOrServerOrListener;
requestListener = listener;
}
- // We bind the request listener, so 'this' always refers to us, not each subserver.
- // This means 'this' is consistent (and this.close() works).
- const boundListener = requestListener.bind(this);
// Create subservers for each supported protocol:
- this._httpServer = new http.Server(boundListener);
- this._http2Server = http2.createServer({}, boundListener);
+ this._httpServer = new http.Server(requestListener);
+ this._http2Server = http2.createServer({}, requestListener);
if (tlsServer) {
// If we've been given a preconfigured TLS server, we use that directly, and
// subscribe to connections there
Loading

2 comments on commit 7288108

@NewEraCracker
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, an heads-up, unless you are using "path-to-regexp": "0.1.7", directly, you should remove this.

Or bump it to a higher version like 0.1.11 if you are indeed using it directly. Test first.

PS: yarn audit - Sadly yarn does not have a tool to fix like npm, but at least it will tell you what modules you should update.

@wll8
Copy link
Owner Author

@wll8 wll8 commented on 7288108 Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I do use it directly. I will try to upgrade.

0592cdf#diff-dd6867b09c3c03ee7d2b137706945be5538d6e0962927d0de886ec7f7e0ac4f5R155

Please sign in to comment.