-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A not responding route when using a middleware #1227
Comments
tried here, it's working fine. you forgot the closing brace on the config method on your app module. |
I’ve run in a similar problem when I incorrectly returned the observable of a interceptor. This caused the whole application to silently fail / not respond at all to web requests. As a user this can be really hard to debug, since there is no error thrown. I think this issue describes a similar behavior? |
this my code can help you in app.module.ts` @module({ // constructor(private readonly connection: Connection) { // } } `in logger.middleware.ts` @Injectable()
} |
i think this method false |
can you say in what situation the error is happening? |
i see one problem with your logic, not the middleware. do you think this can be the problem? TL;DR: try wrapping the userService.getUserByEmail in a try/catch edit: after messing around with the middleware code, try doing this in your configure function in app.module to see if the apply returned properly. i think if it shows your middleware and route, it should be set up properly |
usersService.getUserByEmail() returns if this email in data base |
@barretojs |
Yeah, I just forgot to close the brace in my bug report, in the code, it's normally closed, so the issue isn't in it. |
your code is only this? try putting |
But in the documentation - there is a module with that middleware, but as You can see, my middleware is without a module. |
You know what, I think, that it might be related to platform, but I'm not sure, if I didn't make a mistake. |
@hypeofpipe if this is the only code and you're getting a error, it probably is platform-related. |
@barretojs it's not. I found out that if you remove |
but if you remove the forRoutes your middleware is not getting applied. if you could share a repository with your real code it'd be easier to help |
@barretojs Yeah, I've understood it recently... Um, okay, I'll share it. Here is the link https://github.com/hypeofpipe/images-into-ascii-nestjs |
UPD: If you have the same problem, just use "Functional middleware" like this:
|
@hypeofpipe yeah man, sorry that i wasn't able to help, this is one weird behavior. i tried debugging here but nothing seemed to work, and you middleware seems to be defined properly. but it's good to know that functional middlewares are working better. |
Thank you a lot for Your engagement in this problem :) Yeah, it might be a platform problem, @kamilmysliwiec - what do you think? |
UPD: app.controller.ts
file-validator.pipe.ts
|
Please, use StackOverflow for such questions. We are not here to explain a normal framework behavior. |
The question was reposted on StackOverflow. |
The problem was in my |
I'm experiencing the same problem. No way to make injectable middleware work. @hypeofpipe were you able to solve the initial issue? I'm not sure if your comment to use target=es6 was related to the whole problem or only the use of pipes. For me, es6 configuration did not solve the issue. Going to use functional middleware for now, though it would be of interest to find out why it's not working as intended. |
I am experiencing the same problem. Injectable middleware causes requests matching the url to never return. My middleware is never called. Functional middleware works. I created a minimal test and was able to reproduce it. @nest/common@6.0.2, Debian 9.8 |
@hypeofpipe holy shit dude thank you. This was driving me absolutely insane. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm submitting a...
Current behavior
When adding a middleware to the module, it breaks and whole route (to which a middleware was added) is broken and don't respond too.
Expected behavior
I expect to get an error about it because it doesn't even throw any exceptions and it's very hard to detect using a debugger.
Minimal reproduction of the problem with instructions
app.module.ts
sample.middleware.ts
What is the motivation/use case for changing the behavior?
Unfortunately, I don't know. The code seems legit though.
Environment
The text was updated successfully, but these errors were encountered: