egg 3.12.0 → 3.14.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.
Files changed (3) hide show
  1. package/index.d.ts +25 -7
  2. package/lib/egg.js +6 -3
  3. package/package.json +4 -5
package/index.d.ts CHANGED
@@ -14,9 +14,13 @@ import {
14
14
  EggLoggerOptions,
15
15
  EggContextLogger,
16
16
  } from 'egg-logger';
17
- import { RequestOptions2 as RequestOptions, HttpClientResponse } from 'urllib';
18
17
  import {
19
- RequestURL, RequestOptions as RequestOptionsNext,
18
+ RequestOptions2 as RequestOptionsOld,
19
+ HttpClientResponse as HttpClientResponseOld,
20
+ } from 'urllib';
21
+ import {
22
+ RequestURL,
23
+ RequestOptions as RequestOptionsNext,
20
24
  HttpClientResponse as HttpClientResponseNext,
21
25
  } from 'urllib-next';
22
26
  import {
@@ -49,13 +53,27 @@ declare module 'egg' {
49
53
  // Remove specific property from the specific class
50
54
  type RemoveSpecProp<T, P> = Pick<T, Exclude<keyof T, P>>;
51
55
 
56
+ // Usage:
57
+ // ```ts
58
+ // import { HttpClientRequestURL, HttpClientRequestOptions, HttpClientResponse } from 'egg';
59
+ // async function request(url: HttpClientRequestURL, options: HttpClientRequestOptions): Promise<HttpClientResponse> {
60
+ // return await app.httpclient.request(url, options);
61
+ // }
62
+ // ```
63
+ export type HttpClientRequestURL = RequestURL;
64
+ export type HttpClientRequestOptions = RequestOptionsNext;
65
+ export type HttpClientResponse<T = any> = HttpClientResponseNext<T>;
66
+
52
67
  // Compatible with both urllib@2 and urllib@3 RequestOptions to request
53
68
  export interface EggHttpClient extends EventEmitter {
54
- request<T = any>(url: RequestURL): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
55
- request<T = any>(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
56
- curl<T = any>(url: RequestURL): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
57
- curl<T = any>(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
69
+ request<T = any>(url: HttpClientRequestURL): Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
70
+ request<T = any>(url: HttpClientRequestURL, options: RequestOptionsOld | HttpClientRequestOptions):
71
+ Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
72
+ curl<T = any>(url: HttpClientRequestURL): Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
73
+ curl<T = any>(url: HttpClientRequestURL, options: RequestOptionsOld | HttpClientRequestOptions):
74
+ Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
58
75
  }
76
+
59
77
  interface EggHttpConstructor {
60
78
  new(app: Application): EggHttpClient;
61
79
  }
@@ -278,7 +296,7 @@ declare module 'egg' {
278
296
  /** https.Agent */
279
297
  httpsAgent?: HttpClientBaseConfig;
280
298
  /** Default request args for httpclient */
281
- request?: RequestOptions;
299
+ request?: HttpClientRequestOptions | RequestOptionsOld;
282
300
  /** Whether enable dns cache */
283
301
  enableDNSCache?: boolean;
284
302
  /** Enable proxy request, default is false. */
package/lib/egg.js CHANGED
@@ -417,11 +417,13 @@ class EggApplication extends EggCore {
417
417
  const rundir = this.config.rundir;
418
418
  const dumpFile = path.join(rundir, `${this.type}_timing_${process.pid}.json`);
419
419
  fs.writeFileSync(dumpFile, CircularJSON.stringify(items, null, 2));
420
+ this.coreLogger.info(this.timing.toString());
420
421
  // only disable, not clear bootstrap timing data.
421
422
  this.timing.disable();
422
423
  // show duration >= ${slowBootActionMinDuration}ms action to warnning log
423
424
  for (const item of items) {
424
- if (item.duration >= this.config.dump.timing.slowBootActionMinDuration) {
425
+ // ignore #0 name: Process Start
426
+ if (item.index > 0 && item.duration >= this.config.dump.timing.slowBootActionMinDuration) {
425
427
  this.coreLogger.warn('[egg:core][slow-boot-action] #%d %dms, name: %s',
426
428
  item.index, item.duration, item.name);
427
429
  }
@@ -437,10 +439,11 @@ class EggApplication extends EggCore {
437
439
 
438
440
  _setupTimeoutTimer() {
439
441
  const startTimeoutTimer = setTimeout(() => {
442
+ this.coreLogger.error(this.timing.toString());
440
443
  this.coreLogger.error(`${this.type} still doesn't ready after ${this.config.workerStartTimeout} ms.`);
441
444
  // log unfinished
442
- const json = this.timing.toJSON();
443
- for (const item of json) {
445
+ const items = this.timing.toJSON();
446
+ for (const item of items) {
444
447
  if (item.end) continue;
445
448
  this.coreLogger.error(`unfinished timing item: ${CircularJSON.stringify(item)}`);
446
449
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.12.0",
3
+ "version": "3.14.0",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  "delegates": "^1.0.0",
29
29
  "egg-cluster": "^2.0.0",
30
30
  "egg-cookies": "^2.6.1",
31
- "egg-core": "^5.1.1",
31
+ "egg-core": "^5.3.0",
32
32
  "egg-development": "^2.7.0",
33
33
  "egg-errors": "^2.3.1",
34
34
  "egg-i18n": "^2.1.1",
@@ -64,15 +64,14 @@
64
64
  "@umijs/preset-react": "^2.1.6",
65
65
  "address": "^1.2.1",
66
66
  "antd": "^4.23.2",
67
- "assert-extends": "^1.0.1",
68
67
  "assert-file": "^1.0.0",
69
68
  "coffee": "^5.4.0",
70
69
  "dumi": "^1.1.47",
71
70
  "dumi-theme-egg": "^1.2.2",
72
71
  "egg-bin": "^5",
73
- "egg-mock": "^5.4.0",
72
+ "egg-mock": "^5.9.2",
74
73
  "egg-plugin-puml": "^2.4.0",
75
- "egg-tracer": "^1.1.0",
74
+ "egg-tracer": "^2.0.0",
76
75
  "egg-view-nunjucks": "^2.3.0",
77
76
  "eslint": "^8.23.1",
78
77
  "eslint-config-egg": "^12.0.0",