egg 3.9.0-beta.0 → 3.9.0-beta.1

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/index.d.ts CHANGED
@@ -703,6 +703,13 @@ declare module 'egg' {
703
703
  */
704
704
  runInBackground(scope: (ctx: Context) => void): void;
705
705
 
706
+ /**
707
+ * Run async function in the anonymous context scope
708
+ * @see Context#runInAnonymousContextScope
709
+ * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
710
+ */
711
+ runInAnonymousContextScope(scope: (ctx: Context) => Promise<void>): Promise<void>;
712
+
706
713
  /**
707
714
  * Get current execute ctx async local storage
708
715
  * @returns {AsyncLocalStorage} localStorage - store current execute Context
@@ -251,7 +251,22 @@ class Application extends EggApplication {
251
251
  runInBackground(scope) {
252
252
  const ctx = this.createAnonymousContext();
253
253
  if (!scope.name) scope._name = eggUtils.getCalleeFromStack(true);
254
- ctx.runInBackground(scope);
254
+ this.ctxStorage.run(ctx, () => {
255
+ ctx.runInBackground(scope);
256
+ });
257
+ }
258
+
259
+ /**
260
+ * Run async function in the anonymous context scope
261
+ * @see Context#runInAnonymousContextScope
262
+ * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
263
+ */
264
+ async runInAnonymousContextScope(scope) {
265
+ const ctx = this.createAnonymousContext();
266
+ if (!scope.name) scope._name = eggUtils.getCalleeFromStack(true);
267
+ await this.ctxStorage.run(ctx, async () => {
268
+ await scope(ctx);
269
+ });
255
270
  }
256
271
 
257
272
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.9.0-beta.0",
3
+ "version": "3.9.0-beta.1",
4
4
  "publishConfig": {
5
5
  "tag": "next"
6
6
  },
@@ -81,8 +81,6 @@
81
81
  "koa-static": "^5.0.0",
82
82
  "pedding": "^1.1.0",
83
83
  "prettier": "^2.7.1",
84
- "react": "^16.14.0",
85
- "react-dom": "^16.14.0",
86
84
  "runscript": "^1.5.3",
87
85
  "spy": "^1.0.0",
88
86
  "supertest": "^6.2.4",