question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A method handler is interfering into another handler with same name in another controller.

See original GitHub issue

Bug Report

Current behavior

I had two controllers into two differnt folders and differnt modules, Both of them has a method with same create name.

/admin/entity.controller.ts

    @Controller("admin")
    export class EntityController{
        @Post()
        public async create(@Request() request: any): Promise<List> {
            console.log("request", request) // Logs the Body {"name": "test"} instead of request.
        }
    }

/user/entity.ontroller.ts

    @Controller("user")
    export class EntityController{
        @Post()
        public async create(@Body() entity: Entity) {
            console.log("entity", entity) // logs the body {"name": "test"}
        }
    }

When I do post the following in both routes: {"name": "test"},

curl -X POST http://localhost:3000/admin/ -d '{"name":"test"}'

curl -X POST http://localhost:3000/user/ -d '{"name":"test"}'

It happens that admin create() method logs the body part, not the requests as expected.

It seems to be that the definition of the user controller is interfering into the admin controller and making it to do not work properly.

Environment

  • Nest version: 6.0.0
  • Node version: v10.15.1
  • Platform: Windows 10

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilmysliwieccommented, Jul 29, 2019

Please, provide a minimal repository which reproduces your issue.

1reaction
xyunshcommented, Jul 30, 2019

same issue @kamilmysliwiec there is a repo https://github.com/xyunsh/samenamed

http://localhost:3000/user1/details controller named UserController -> /user1/details http://localhost:3000/user2/details controller named UserController -> get error moduleb’s UserController not work.

http://localhost:3000/usera/details controller named UseraController-> /usera/details http://localhost:3000/userb/details controller named UserbController-> /userb/details modulea & moudleb’s controllers both work well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NestJS - A method handler is interfering into ... - Stack Overflow
I had two controllers into two differnt folders into two different modules, Both of them has a method with same create name.
Read more >
Lightning Components: Unable to handle an event
Now i am able to handle the event if put a handler in the same component, but if i try to handle the...
Read more >
Handling Events :: Eloquent JavaScript
Calling its addEventListener method registers the second argument to be called whenever the event described by its first argument occurs. Events and DOM...
Read more >
Interceptors | NestJS - A progressive Node.js framework
The CallHandler interface implements the handle() method, which you can use to invoke the route handler method at some point in your interceptor....
Read more >
A Definitive Guide to Handling Errors in JavaScript - Kinsta
When your code contains entities that are too large for the JavaScript engine (e.g. too many switch cases, too large array initializers, too ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found