You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
The Asynchronous middleware does not work within controller
code e.g:
middleware file:
@Injectable()exportclassResponseMiddlewareimplementsNestMiddleware{asyncresolve(name: string): Promise<MiddlewareFunction>{returnasync(req,res,next)=>{try{console.log(`Request...`,name);//step into breakpoint 1res.state ? void(0) : res.state={};//step into breakpoint 2awaitnext();//step into breakpoint 3res.json(res.body ? res.body : {//step into breakpoint 5code: res.state.code!==undefined ? res.state.code : 0,data: res.state.data!==undefined ? res.state.data : {},});}catch(e){console.error('Catch Error: %o',e);res.status(200);res.json({code: -1,error: e&&e.message ? e.message : e.toString()});// throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);}}}}
@Controller('weapp')exportclassWxappController{
@Get('')publicasyncroot(@Req()req, @Res()res): Promise<any>{res.state.data={//step into breakpoint 4msg: 'hello',};}}
Expected behavior
To visit url "/weapp", the result of my expectation is step 1->2->3->4->5, but the actual result is 1->2->3->5->4 and even this request being hang up, no response return
Minimal reproduction of the problem with instructions
Asynchronous middleware does not work within controller.
What is the motivation / use case for changing the behavior?
I want to change the response's object by using middleware
I'm submitting a...
Current behavior
The Asynchronous middleware does not work within controller
code e.g:
middleware file:
module file:
controller file:
Expected behavior
To visit url "/weapp", the result of my expectation is step 1->2->3->4->5, but the actual result is 1->2->3->5->4 and even this request being hang up, no response return
Minimal reproduction of the problem with instructions
Asynchronous middleware does not work within controller.
What is the motivation / use case for changing the behavior?
I want to change the response's object by using middleware
Environment
The text was updated successfully, but these errors were encountered: