Skip to content

Commit

Permalink
fix: use gals lib
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 19, 2023
1 parent 4275314 commit 8e51375
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/egg.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const assert = require('assert');
const { AsyncLocalStorage } = require('async_hooks');
const fs = require('fs');
const KoaApplication = require('koa');
const EggConsoleLogger = require('egg-logger').EggConsoleLogger;
const debug = require('debug')('egg-core');
const is = require('is-type-of');
const co = require('co');
const Router = require('@eggjs/router').EggRouter;
const { getAsyncLocalStorage } = require('gals');
const BaseContextClass = require('./utils/base_context_class');
const utils = require('./utils');
const Timing = require('./utils/timing');
Expand All @@ -16,7 +16,6 @@ const DEPRECATE = Symbol('EggCore#deprecate');
const ROUTER = Symbol('EggCore#router');
const EGG_LOADER = Symbol.for('egg#loader');
const CLOSE_PROMISE = Symbol('EggCore#closePromise');
const EGG_CTX_STORAGE = Symbol.for('egg#ctxStorage');

class EggCore extends KoaApplication {

Expand All @@ -40,10 +39,7 @@ class EggCore extends KoaApplication {
// disable koa als and use egg logic
super({ asyncLocalStorage: false });
// can access the AsyncLocalStorage instance in global
if (!global[EGG_CTX_STORAGE]) {
global[EGG_CTX_STORAGE] = new AsyncLocalStorage();
}
this.ctxStorage = global[EGG_CTX_STORAGE];
this.ctxStorage = getAsyncLocalStorage();

this.timing = new Timing();

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"egg-logger": "^3.1.0",
"egg-path-matching": "^1.0.1",
"extend2": "^1.0.0",
"gals": "^1.0.1",
"get-ready": "^2.0.1",
"globby": "^11.0.2",
"is-type-of": "^1.2.1",
Expand Down

0 comments on commit 8e51375

Please sign in to comment.