#nestjs starts failing after notfoundexception

5 messages · Page 1 of 1 (latest)

elfin trail
#

Hello,

I have a really strange problem with my local nestjs setup.

As soon as I have a 404, fired in a service like:

throw new NotFoundException("Could not find node with id " + drop.id);

the nestjs (started via yarn start:dev) does not answer anymore (ECONNREFUSED). When I restart the process, everything is back to normal.

the log statement by the service is:

NotFoundException: Could not find node with id og7aucey at /Users/haha/Documents/projects/hihi/app-server/src/kong/node.service.ts:74:27

The handler of the route is this:

@Put("/position") async position(@Body() dragDrop: NodePositionings) : Promise<void> { await this.nodeService.position(dragDrop) }

The exception is fired like that, but it does not matter in which context it is done.

findById = async (nodeId: string) : Promise<NodeEntity> => { const node = await this.repository.findOne({where: {id: nodeId}}) if (node) { return node; } else { throw new NotFoundException("Could not find node with id " + nodeId); } }

Any ideas? I really don't get it, as I am using a very similar setup with another nestjs project.

#

nestjs starts failing after notfoundexception

hybrid schooner
#

show use the handler of the route

elfin trail
#

sure, have a look in the original post.

solid slate
#

That smells of an uncaught rejected promise (something not awaited and failing outside any try/catch blocks). Do you receive a 404 on the client also, or does it only show in the console?