Skip to content

Commit

Permalink
fix(create-server-hack): use currentContext()
Browse files Browse the repository at this point in the history
instead of getting it from process.domain.currentContext
  • Loading branch information
mapleeit committed Dec 2, 2020
1 parent 3acbf96 commit e0a0429
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/core/runtime/create-server.hack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const httpCreateServerHack = (): void => {
): ReturnType<typeof res.writeHead> => {
timestamps.onResponse = new Date();

const context = process.domain.currentContext;
const context = currentContext();

eventBus.emit(EVENT_LIST.RESPONSE_START, {
req, res, context
Expand All @@ -92,7 +92,7 @@ export const httpCreateServerHack = (): void => {
})(res.writeHead);

res.once("finish", () => {
const context = process.domain.currentContext;
const context = currentContext();

context.currentRequest = {
SN: context.SN,
Expand Down Expand Up @@ -154,7 +154,7 @@ export const httpCreateServerHack = (): void => {
res.once("close", () => {
timestamps.responseClose = new Date();

const context = process.domain.currentContext;
const context = currentContext();

clearDomain();

Expand All @@ -164,10 +164,7 @@ export const httpCreateServerHack = (): void => {
});

d.run(() => {
// 初始化一下 Context
currentContext();

const context = process.domain.currentContext;
const context = currentContext();
eventBus.emit(EVENT_LIST.REQUEST_START, {
req, context
});
Expand Down

0 comments on commit e0a0429

Please sign in to comment.