Skip to content

review-object.controller.js: application can crash if a Mongoose operation fails #1645

@ElectricNroff

Description

@ElectricNroff

This file does not use a pattern such as:

catch (err) {
    next(err)
}

Code that has an await of a "repo." function call can throw if, for example, a Mongoose operation fails. In most configurations of Express 4.x with Node 15 and later, this terminates the process.

In two situations, there is an explicit re-throw but other functions are affected as well:

} catch (updateErr) {
await session.abortTransaction()
throw updateErr

} catch (rejectErr) {
await session.abortTransaction()
throw rejectErr

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Needs Triage

Status

In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions