egg 2.29.3 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +67 -3
- package/index.d.ts +4 -0
- package/lib/agent.js +18 -6
- package/lib/core/dnscache_httpclient.js +9 -0
- package/lib/core/httpclient.js +14 -1
- package/package.json +2 -1
package/History.md
CHANGED
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# History
|
|
2
2
|
|
|
3
|
+
## 2021-11-15, Version 2.32.0 @atian25
|
|
4
|
+
|
|
5
|
+
### Notable Changes
|
|
6
|
+
|
|
7
|
+
* **features**
|
|
8
|
+
* handle ENETUNREACH error on httpclient
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
* [[`189c47804`](http://github.com/eggjs/egg/commit/189c478048d820b7b1a6ba6e8bce3444604876ff)] - feat: handle ENETUNREACH error on httpclient (#4792) (fengmk2 <<fengmk2@gmail.com>>)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 2021-10-18, Version 2.31.0 @killagu
|
|
16
|
+
|
|
17
|
+
### Notable Changes
|
|
18
|
+
|
|
19
|
+
* **typing**
|
|
20
|
+
* support ssrf typing in config
|
|
21
|
+
|
|
22
|
+
### Commits
|
|
23
|
+
|
|
24
|
+
* [[`debfda7ab`](https://github.com/eggjs/egg/commit/debfda7ab38f4893b6f122abfbf3e5288af1441e)] - feat(config): support ssrf field in security config. (#4778) (Jasin Yip <<yejunxing@gmail.com>>)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## 2021-08-09, Version 2.30.0 @mansonchor
|
|
28
|
+
|
|
29
|
+
### Notable Changes
|
|
30
|
+
|
|
31
|
+
* **features**
|
|
32
|
+
* support disableDNSCache in one request even though config set to `enableDNSCache: true`
|
|
33
|
+
|
|
34
|
+
* **docs**
|
|
35
|
+
* update ts docs, add missing zh-CN doc
|
|
36
|
+
* typo fix
|
|
37
|
+
|
|
38
|
+
### Commits
|
|
39
|
+
|
|
40
|
+
* [[`13dd55076`](https://github.com/eggjs/egg.git/commit/13dd5507694a57a11e12d1ac6f71ba4a562d88c0)] - feat: support disableDNSCache by request args handle (#4728) (mansonchor.github.com <<mansonchor1987@gmail.com>>)
|
|
41
|
+
* [[`1b4fde454`](https://github.com/eggjs/egg.git/commit/1b4fde454d2d61200a8b066ba841ad6d81b5b69d)] - unittest: rename and remove some useless tests (#4705) (Maledong <<maledong_public@foxmail.com>>)
|
|
42
|
+
* [[`156980d36`](https://github.com/eggjs/egg.git/commit/156980d369570531c1ef9cf842f02f513b56fe4a)] - doc: Typo fixture (#4707) (Maledong <<maledong_public@foxmail.com>>)
|
|
43
|
+
* [[`27aa49b59`](https://github.com/eggjs/egg.git/commit/27aa49b5945f08fa6b636479cf4cba7822e3af2d)] - doc: Typo fixture:「,」->「,」 (#4708) (陈煮酒 <<501205587@qq.com>>)
|
|
44
|
+
* [[`1f02a8d45`](https://github.com/eggjs/egg.git/commit/1f02a8d4560ca3334425e646c1ac87226aba3a63)] - doc: Add the missing zh-CN trans for typescript (#4703) (Maledong <<52018749+MaledongGit@users.noreply.github.com>>)
|
|
45
|
+
* [[`f5cf0d965`](https://github.com/eggjs/egg.git/commit/f5cf0d965fa4077da10e87f070e113496077872c)] - doc: "登陆" should be "登录" (#4697) (HOU Ce <<594965698@qq.com>>)
|
|
46
|
+
* [[`750558400`](https://github.com/eggjs/egg.git/commit/750558400e3bd5f39658dfcbedd4af7bc0bdda2a)] - docs: update ts docs (#4666) (吖猩 <<whxaxes@gmail.com>>)
|
|
47
|
+
* [[`93d2b04b9`](https://github.com/eggjs/egg.git/commit/93d2b04b985145f27a39335300a78002a61da2a8)] - docs: fix loaderUpdate.md didReady example (#4652) (shadyzoz <<shadyzoz@icloud.com>>)
|
|
48
|
+
|
|
49
|
+
## 2021-04-13, Version 2.29.4 @popomore
|
|
50
|
+
|
|
51
|
+
### Notable Changes
|
|
52
|
+
|
|
53
|
+
* **fixes**
|
|
54
|
+
* remove internal interval handler when close agent
|
|
55
|
+
* **docs**
|
|
56
|
+
* Added english doc to how-to-migrate-from-1.x, Thx @ZixiaoWang
|
|
57
|
+
* typo improvement
|
|
58
|
+
|
|
59
|
+
### Commits
|
|
60
|
+
|
|
61
|
+
* [[`ce234226b`](http://github.com/eggjs/egg/commit/ce234226bf0c43f03aedf727a7d195ae4175c01f)] - fix: remove internal interval handler when close agent (#4654) (Harry Chen <<czy88840616@gmail.com>>)
|
|
62
|
+
* [[`6a6d68fb2`](http://github.com/eggjs/egg/commit/6a6d68fb228a3eae9b5cab3ba7afe0892d5e08ea)] - Typo fixture:制定 -> 指定 (#4639) (华晨 <<chanjsq@gmail.com>>)
|
|
63
|
+
* [[`603c74b58`](http://github.com/eggjs/egg/commit/603c74b581d6b3a9ad80170335425b0876ffcb1f)] - docs: Added english doc to how-to-migrate-from-1.x (#4630) (Jacky Wang <<www.wangzixiao@126.com>>)
|
|
64
|
+
* [[`693df6066`](http://github.com/eggjs/egg/commit/693df60661735008e8a758258fc2df0bb9783f04)] - docs: fix schedule reference (#4556) (xuxu <<must414@163.com>>)
|
|
65
|
+
* [[`4ebbe8143`](http://github.com/eggjs/egg/commit/4ebbe814386102377870959129e831a3b20133c1)] - docs: fix typo (#4596) (suinia <<suini_a@163.com>>)
|
|
66
|
+
|
|
3
67
|
## 2021-02-19, Version 2.29.3 @killa
|
|
4
68
|
|
|
5
69
|
### Notable Changes
|
|
@@ -8,7 +72,7 @@
|
|
|
8
72
|
* fix ctx body typing
|
|
9
73
|
|
|
10
74
|
### Commits
|
|
11
|
-
* [[`e9fba1b7b`](http://github.com/eggjs/egg/commit/e9fba1b7bbe3f54b023262aeb5487b31047e119e)] - fix: fix ctx body as any (#4613) (killa <<killa123@126.com>>)
|
|
75
|
+
* [[`e9fba1b7b`](http://github.com/eggjs/egg/commit/e9fba1b7bbe3f54b023262aeb5487b31047e119e)] - fix: fix ctx body as any (#4613) (killa <<killa123@126.com>>)
|
|
12
76
|
|
|
13
77
|
## 2021-02-18, Version 2.29.2 @killa
|
|
14
78
|
|
|
@@ -17,14 +81,14 @@
|
|
|
17
81
|
* **fixes**
|
|
18
82
|
* fix query typing
|
|
19
83
|
* add overrideIgnore define
|
|
20
|
-
|
|
84
|
+
|
|
21
85
|
### Commits
|
|
22
86
|
|
|
23
87
|
* [[`99682e4bd`](http://github.com/eggjs/egg/commit/99682e4bd5afe1697cab02001e919b967c264869)] - fix: fix query typing (#4611) (killa <<killa123@126.com>>)
|
|
24
88
|
* [[`26017ee2e`](http://github.com/eggjs/egg/commit/26017ee2e49bd8a42b660baabe31284e00f81bcb)] - chore: fix comment typo at request.js (#4513) (Albert 理斯特 <<shuaizhexu@gmail.com>>)
|
|
25
89
|
* [[`34048c275`](http://github.com/eggjs/egg/commit/34048c275afe1126716ef4265b667169e9866e53)] - fix: add overrideIgnore define (#4490) (kotot <<317643941@qq.com>>)
|
|
26
90
|
* [[`d652658d1`](http://github.com/eggjs/egg/commit/d652658d1205d0fbc73b4417c2ae54ee0a24f395)] - docs: d2 ads (#4508) (Suyi <<thonatos.yang@gmail.com>>)
|
|
27
|
-
|
|
91
|
+
|
|
28
92
|
## 2020-10-19, Version 2.29.1 @atian25
|
|
29
93
|
|
|
30
94
|
### Notable Changes
|
package/index.d.ts
CHANGED
|
@@ -466,6 +466,10 @@ declare module 'egg' {
|
|
|
466
466
|
protocolWhiteList: string[];
|
|
467
467
|
defaultMiddleware: string;
|
|
468
468
|
csrf: any;
|
|
469
|
+
ssrf: {
|
|
470
|
+
ipBlackList: string[];
|
|
471
|
+
checkAddress?(ip: string): boolean;
|
|
472
|
+
};
|
|
469
473
|
xframe: {
|
|
470
474
|
enable: boolean;
|
|
471
475
|
value: 'SAMEORIGIN' | 'DENY' | 'ALLOW-FROM';
|
package/lib/agent.js
CHANGED
|
@@ -26,10 +26,13 @@ class Agent extends EggApplication {
|
|
|
26
26
|
// dump config after loaded, ensure all the dynamic modifications will be recorded
|
|
27
27
|
const dumpStartTime = Date.now();
|
|
28
28
|
this.dumpConfig();
|
|
29
|
-
this.coreLogger.info(
|
|
29
|
+
this.coreLogger.info(
|
|
30
|
+
'[egg:core] dump config after load, %s',
|
|
31
|
+
ms(Date.now() - dumpStartTime)
|
|
32
|
+
);
|
|
30
33
|
|
|
31
34
|
// keep agent alive even it doesn't have any io tasks
|
|
32
|
-
setInterval(() => {}, 24 * 60 * 60 * 1000);
|
|
35
|
+
this.agentAliveHandler = setInterval(() => {}, 24 * 60 * 60 * 1000);
|
|
33
36
|
|
|
34
37
|
this._uncaughtExceptionHandler = this._uncaughtExceptionHandler.bind(this);
|
|
35
38
|
process.on('uncaughtException', this._uncaughtExceptionHandler);
|
|
@@ -55,7 +58,13 @@ class Agent extends EggApplication {
|
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
_wrapMessenger() {
|
|
58
|
-
for (const methodName of [
|
|
61
|
+
for (const methodName of [
|
|
62
|
+
'broadcast',
|
|
63
|
+
'sendTo',
|
|
64
|
+
'sendToApp',
|
|
65
|
+
'sendToAgent',
|
|
66
|
+
'sendRandom',
|
|
67
|
+
]) {
|
|
59
68
|
wrapMethod(methodName, this.messenger, this.coreLogger);
|
|
60
69
|
}
|
|
61
70
|
|
|
@@ -63,8 +72,11 @@ class Agent extends EggApplication {
|
|
|
63
72
|
const originMethod = messenger[methodName];
|
|
64
73
|
messenger[methodName] = function() {
|
|
65
74
|
const stack = new Error().stack.split('\n').slice(1).join('\n');
|
|
66
|
-
logger.warn(
|
|
67
|
-
|
|
75
|
+
logger.warn(
|
|
76
|
+
"agent can't call %s before server started\n%s",
|
|
77
|
+
methodName,
|
|
78
|
+
stack
|
|
79
|
+
);
|
|
68
80
|
originMethod.apply(this, arguments);
|
|
69
81
|
};
|
|
70
82
|
messenger.prependOnceListener('egg-ready', () => {
|
|
@@ -75,9 +87,9 @@ class Agent extends EggApplication {
|
|
|
75
87
|
|
|
76
88
|
close() {
|
|
77
89
|
process.removeListener('uncaughtException', this._uncaughtExceptionHandler);
|
|
90
|
+
clearInterval(this.agentAliveHandler);
|
|
78
91
|
return super.close();
|
|
79
92
|
}
|
|
80
|
-
|
|
81
93
|
}
|
|
82
94
|
|
|
83
95
|
module.exports = Agent;
|
|
@@ -27,6 +27,11 @@ class DNSCacheHttpClient extends HttpClient {
|
|
|
27
27
|
// the callback style
|
|
28
28
|
if (callback) {
|
|
29
29
|
this.app.deprecate('[dnscache_httpclient] We now support async for this function, so callback isn\'t recommended.');
|
|
30
|
+
// disable dns cache in request by args handle
|
|
31
|
+
if (args && args.enableDNSCache === false) {
|
|
32
|
+
super.request(url, args, callback);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
30
35
|
this[DNSLOOKUP](url, args)
|
|
31
36
|
.then(result => {
|
|
32
37
|
return super.request(result.url, result.args);
|
|
@@ -38,6 +43,10 @@ class DNSCacheHttpClient extends HttpClient {
|
|
|
38
43
|
|
|
39
44
|
// the Promise style
|
|
40
45
|
return (async () => {
|
|
46
|
+
// disable dns cache in request by args handle
|
|
47
|
+
if (args && args.enableDNSCache === false) {
|
|
48
|
+
return super.request(url, args);
|
|
49
|
+
}
|
|
41
50
|
const result = await this[DNSLOOKUP](url, args);
|
|
42
51
|
return super.request(result.url, result.args);
|
|
43
52
|
})();
|
package/lib/core/httpclient.js
CHANGED
|
@@ -4,6 +4,13 @@ const Agent = require('agentkeepalive');
|
|
|
4
4
|
const HttpsAgent = require('agentkeepalive').HttpsAgent;
|
|
5
5
|
const urllib = require('urllib');
|
|
6
6
|
const ms = require('humanize-ms');
|
|
7
|
+
const { FrameworkBaseError } = require('egg-errors');
|
|
8
|
+
|
|
9
|
+
class HttpClientError extends FrameworkBaseError {
|
|
10
|
+
get module() {
|
|
11
|
+
return 'httpclient';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
7
14
|
|
|
8
15
|
class HttpClient extends urllib.HttpClient2 {
|
|
9
16
|
constructor(app) {
|
|
@@ -42,7 +49,13 @@ class HttpClient extends urllib.HttpClient2 {
|
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
// the Promise style
|
|
45
|
-
return super.request(url, args)
|
|
52
|
+
return super.request(url, args)
|
|
53
|
+
.catch(err => {
|
|
54
|
+
if (err.code === 'ENETUNREACH') {
|
|
55
|
+
throw HttpClientError.create(err.message, err.code);
|
|
56
|
+
}
|
|
57
|
+
throw err;
|
|
58
|
+
});
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
curl(url, args, callback) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "egg",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.32.0",
|
|
4
4
|
"description": "A web framework's framework for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"egg-cookies": "^2.3.0",
|
|
28
28
|
"egg-core": "^4.18.0",
|
|
29
29
|
"egg-development": "^2.4.2",
|
|
30
|
+
"egg-errors": "^2.3.0",
|
|
30
31
|
"egg-i18n": "^2.0.0",
|
|
31
32
|
"egg-jsonp": "^2.0.0",
|
|
32
33
|
"egg-logger": "^2.3.2",
|