NestJS and Express causing intermittent UnhandledPromiseRejectionWarning
up vote
1
down vote
favorite
I cannot for the life of me cannot figure this out. It happens once every so often doesn't cause any issues with the application itself but i have no idea what is causing this. Im making simultaneous calls to the api from the browser if that has anything to do with it.
[Nest] 16608 - 11/7/2018, 1:23:08 PM [NestApplication] Nest application successfully started
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/pending-count +14943ms
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/revision-count +16ms
(node:14968) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:469:11)
at ServerResponse.header (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:767:10)
at ServerResponse.send (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:170:12)
at ServerResponse.json (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:267:15)
at ExpressAdapter.reply (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreadaptersexpress-adapter.js:44:52)
at ExceptionsHandler.catch (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsbase-exception-filter.js:16:33)
at ExceptionsHandler.next (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsexceptions-handler.js:15:20)
at C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscorerouterrouter-proxy.js:23:35
at Layer.handle_error (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterlayer.js:71:5)
at trim_prefix (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterindex.js:315:13)
(node:14968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I've reduced the calls to a pretty simple function, and make sure the call is returning a unique value (i thought it might be a 304 issue)
@Get('revision-count')
async countRevisions(@User() user, @Param() params) {
user.count ++;
return {
status: 'success',
data: {
rand: user.count,
}
};
}
this was happening prior to the middleware
javascript node.js typescript express nestjs
add a comment |
up vote
1
down vote
favorite
I cannot for the life of me cannot figure this out. It happens once every so often doesn't cause any issues with the application itself but i have no idea what is causing this. Im making simultaneous calls to the api from the browser if that has anything to do with it.
[Nest] 16608 - 11/7/2018, 1:23:08 PM [NestApplication] Nest application successfully started
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/pending-count +14943ms
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/revision-count +16ms
(node:14968) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:469:11)
at ServerResponse.header (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:767:10)
at ServerResponse.send (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:170:12)
at ServerResponse.json (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:267:15)
at ExpressAdapter.reply (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreadaptersexpress-adapter.js:44:52)
at ExceptionsHandler.catch (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsbase-exception-filter.js:16:33)
at ExceptionsHandler.next (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsexceptions-handler.js:15:20)
at C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscorerouterrouter-proxy.js:23:35
at Layer.handle_error (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterlayer.js:71:5)
at trim_prefix (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterindex.js:315:13)
(node:14968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I've reduced the calls to a pretty simple function, and make sure the call is returning a unique value (i thought it might be a 304 issue)
@Get('revision-count')
async countRevisions(@User() user, @Param() params) {
user.count ++;
return {
status: 'success',
data: {
rand: user.count,
}
};
}
this was happening prior to the middleware
javascript node.js typescript express nestjs
Is it possible that somewhere in your application you have an async function that isn't being awaited? The stack trace indicates that your code is falling into the global error handler which returns a default error message but in this case your application has already returned a response to the client so the error handler itself is failing. I had this exact same issue in my app and the underlying was a promise that wasn't being awaited
– Jesse Carter
Nov 19 at 19:22
i was thinking its the Nest Framework im using or a library.. i have no idea how to track it down though
– Ricardo Saracino
Nov 20 at 21:52
Are you able to upload a small repo that reproduces this issue?
– Jesse Carter
Nov 21 at 14:06
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I cannot for the life of me cannot figure this out. It happens once every so often doesn't cause any issues with the application itself but i have no idea what is causing this. Im making simultaneous calls to the api from the browser if that has anything to do with it.
[Nest] 16608 - 11/7/2018, 1:23:08 PM [NestApplication] Nest application successfully started
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/pending-count +14943ms
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/revision-count +16ms
(node:14968) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:469:11)
at ServerResponse.header (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:767:10)
at ServerResponse.send (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:170:12)
at ServerResponse.json (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:267:15)
at ExpressAdapter.reply (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreadaptersexpress-adapter.js:44:52)
at ExceptionsHandler.catch (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsbase-exception-filter.js:16:33)
at ExceptionsHandler.next (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsexceptions-handler.js:15:20)
at C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscorerouterrouter-proxy.js:23:35
at Layer.handle_error (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterlayer.js:71:5)
at trim_prefix (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterindex.js:315:13)
(node:14968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I've reduced the calls to a pretty simple function, and make sure the call is returning a unique value (i thought it might be a 304 issue)
@Get('revision-count')
async countRevisions(@User() user, @Param() params) {
user.count ++;
return {
status: 'success',
data: {
rand: user.count,
}
};
}
this was happening prior to the middleware
javascript node.js typescript express nestjs
I cannot for the life of me cannot figure this out. It happens once every so often doesn't cause any issues with the application itself but i have no idea what is causing this. Im making simultaneous calls to the api from the browser if that has anything to do with it.
[Nest] 16608 - 11/7/2018, 1:23:08 PM [NestApplication] Nest application successfully started
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/pending-count +14943ms
[Nest] 16608 - 11/7/2018, 1:23:23 PM [LoggerMiddleware] Request /api/observation-statement/revision-count +16ms
(node:14968) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:469:11)
at ServerResponse.header (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:767:10)
at ServerResponse.send (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:170:12)
at ServerResponse.json (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibresponse.js:267:15)
at ExpressAdapter.reply (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreadaptersexpress-adapter.js:44:52)
at ExceptionsHandler.catch (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsbase-exception-filter.js:16:33)
at ExceptionsHandler.next (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscoreexceptionsexceptions-handler.js:15:20)
at C:UsersRicardo SaracinoIdeaProjectssor-apinode_modules@nestjscorerouterrouter-proxy.js:23:35
at Layer.handle_error (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterlayer.js:71:5)
at trim_prefix (C:UsersRicardo SaracinoIdeaProjectssor-apinode_modulesexpresslibrouterindex.js:315:13)
(node:14968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I've reduced the calls to a pretty simple function, and make sure the call is returning a unique value (i thought it might be a 304 issue)
@Get('revision-count')
async countRevisions(@User() user, @Param() params) {
user.count ++;
return {
status: 'success',
data: {
rand: user.count,
}
};
}
this was happening prior to the middleware
javascript node.js typescript express nestjs
javascript node.js typescript express nestjs
edited Nov 9 at 21:10
Kim Kern
6,89122241
6,89122241
asked Nov 7 at 18:28
Ricardo Saracino
175112
175112
Is it possible that somewhere in your application you have an async function that isn't being awaited? The stack trace indicates that your code is falling into the global error handler which returns a default error message but in this case your application has already returned a response to the client so the error handler itself is failing. I had this exact same issue in my app and the underlying was a promise that wasn't being awaited
– Jesse Carter
Nov 19 at 19:22
i was thinking its the Nest Framework im using or a library.. i have no idea how to track it down though
– Ricardo Saracino
Nov 20 at 21:52
Are you able to upload a small repo that reproduces this issue?
– Jesse Carter
Nov 21 at 14:06
add a comment |
Is it possible that somewhere in your application you have an async function that isn't being awaited? The stack trace indicates that your code is falling into the global error handler which returns a default error message but in this case your application has already returned a response to the client so the error handler itself is failing. I had this exact same issue in my app and the underlying was a promise that wasn't being awaited
– Jesse Carter
Nov 19 at 19:22
i was thinking its the Nest Framework im using or a library.. i have no idea how to track it down though
– Ricardo Saracino
Nov 20 at 21:52
Are you able to upload a small repo that reproduces this issue?
– Jesse Carter
Nov 21 at 14:06
Is it possible that somewhere in your application you have an async function that isn't being awaited? The stack trace indicates that your code is falling into the global error handler which returns a default error message but in this case your application has already returned a response to the client so the error handler itself is failing. I had this exact same issue in my app and the underlying was a promise that wasn't being awaited
– Jesse Carter
Nov 19 at 19:22
Is it possible that somewhere in your application you have an async function that isn't being awaited? The stack trace indicates that your code is falling into the global error handler which returns a default error message but in this case your application has already returned a response to the client so the error handler itself is failing. I had this exact same issue in my app and the underlying was a promise that wasn't being awaited
– Jesse Carter
Nov 19 at 19:22
i was thinking its the Nest Framework im using or a library.. i have no idea how to track it down though
– Ricardo Saracino
Nov 20 at 21:52
i was thinking its the Nest Framework im using or a library.. i have no idea how to track it down though
– Ricardo Saracino
Nov 20 at 21:52
Are you able to upload a small repo that reproduces this issue?
– Jesse Carter
Nov 21 at 14:06
Are you able to upload a small repo that reproduces this issue?
– Jesse Carter
Nov 21 at 14:06
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195616%2fnestjs-and-express-causing-intermittent-unhandledpromiserejectionwarning%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is it possible that somewhere in your application you have an async function that isn't being awaited? The stack trace indicates that your code is falling into the global error handler which returns a default error message but in this case your application has already returned a response to the client so the error handler itself is failing. I had this exact same issue in my app and the underlying was a promise that wasn't being awaited
– Jesse Carter
Nov 19 at 19:22
i was thinking its the Nest Framework im using or a library.. i have no idea how to track it down though
– Ricardo Saracino
Nov 20 at 21:52
Are you able to upload a small repo that reproduces this issue?
– Jesse Carter
Nov 21 at 14:06