Continue promise.all loop if error caught in lambda node scenario
I have a simple node script run in AWS lambda function. Each promise is an AWS sdk call which can fail, but for the most part I want to ignore the failures and continue.
When I catch the error and just ignore it as follows, I get the UnhandledPromiseRejectionWarning
error
Promise.all(promises).then(() => {
callback(null, 'completed');
}).catch(err => {
console.log('aws errors!', err);
});
Each promise is basically a putScheduledUpdateGroupAction
call as follows
return new Promise((resolve, reject) => {
aws.putScheduledUpdateGroupAction(params, function(err, data) {
if (err) {
reject(err);
}
else {
resolve(data);
}
});
});
What needs to happen to ignore the AWS errors and continue without this rejection error ? I need it to continue in a lambda situation, not stand alone node.
node.js amazon-web-services promise
add a comment |
I have a simple node script run in AWS lambda function. Each promise is an AWS sdk call which can fail, but for the most part I want to ignore the failures and continue.
When I catch the error and just ignore it as follows, I get the UnhandledPromiseRejectionWarning
error
Promise.all(promises).then(() => {
callback(null, 'completed');
}).catch(err => {
console.log('aws errors!', err);
});
Each promise is basically a putScheduledUpdateGroupAction
call as follows
return new Promise((resolve, reject) => {
aws.putScheduledUpdateGroupAction(params, function(err, data) {
if (err) {
reject(err);
}
else {
resolve(data);
}
});
});
What needs to happen to ignore the AWS errors and continue without this rejection error ? I need it to continue in a lambda situation, not stand alone node.
node.js amazon-web-services promise
Can you post a Minimal, Complete, and Verifiable example? Where does the error get thrown, exactly?
– CertainPerformance
Jan 1 at 22:40
@CertainPerformance I've added code for the promise created
– yoyoma
Jan 1 at 22:58
You should use the promisified variant of the AWS call. Simply return aws.putScheduledUpdateGroupAction(params).promise().
– jarmod
Jan 1 at 23:33
add a comment |
I have a simple node script run in AWS lambda function. Each promise is an AWS sdk call which can fail, but for the most part I want to ignore the failures and continue.
When I catch the error and just ignore it as follows, I get the UnhandledPromiseRejectionWarning
error
Promise.all(promises).then(() => {
callback(null, 'completed');
}).catch(err => {
console.log('aws errors!', err);
});
Each promise is basically a putScheduledUpdateGroupAction
call as follows
return new Promise((resolve, reject) => {
aws.putScheduledUpdateGroupAction(params, function(err, data) {
if (err) {
reject(err);
}
else {
resolve(data);
}
});
});
What needs to happen to ignore the AWS errors and continue without this rejection error ? I need it to continue in a lambda situation, not stand alone node.
node.js amazon-web-services promise
I have a simple node script run in AWS lambda function. Each promise is an AWS sdk call which can fail, but for the most part I want to ignore the failures and continue.
When I catch the error and just ignore it as follows, I get the UnhandledPromiseRejectionWarning
error
Promise.all(promises).then(() => {
callback(null, 'completed');
}).catch(err => {
console.log('aws errors!', err);
});
Each promise is basically a putScheduledUpdateGroupAction
call as follows
return new Promise((resolve, reject) => {
aws.putScheduledUpdateGroupAction(params, function(err, data) {
if (err) {
reject(err);
}
else {
resolve(data);
}
});
});
What needs to happen to ignore the AWS errors and continue without this rejection error ? I need it to continue in a lambda situation, not stand alone node.
node.js amazon-web-services promise
node.js amazon-web-services promise
edited Jan 1 at 22:57
yoyoma
asked Jan 1 at 22:39
yoyomayoyoma
71221125
71221125
Can you post a Minimal, Complete, and Verifiable example? Where does the error get thrown, exactly?
– CertainPerformance
Jan 1 at 22:40
@CertainPerformance I've added code for the promise created
– yoyoma
Jan 1 at 22:58
You should use the promisified variant of the AWS call. Simply return aws.putScheduledUpdateGroupAction(params).promise().
– jarmod
Jan 1 at 23:33
add a comment |
Can you post a Minimal, Complete, and Verifiable example? Where does the error get thrown, exactly?
– CertainPerformance
Jan 1 at 22:40
@CertainPerformance I've added code for the promise created
– yoyoma
Jan 1 at 22:58
You should use the promisified variant of the AWS call. Simply return aws.putScheduledUpdateGroupAction(params).promise().
– jarmod
Jan 1 at 23:33
Can you post a Minimal, Complete, and Verifiable example? Where does the error get thrown, exactly?
– CertainPerformance
Jan 1 at 22:40
Can you post a Minimal, Complete, and Verifiable example? Where does the error get thrown, exactly?
– CertainPerformance
Jan 1 at 22:40
@CertainPerformance I've added code for the promise created
– yoyoma
Jan 1 at 22:58
@CertainPerformance I've added code for the promise created
– yoyoma
Jan 1 at 22:58
You should use the promisified variant of the AWS call. Simply return aws.putScheduledUpdateGroupAction(params).promise().
– jarmod
Jan 1 at 23:33
You should use the promisified variant of the AWS call. Simply return aws.putScheduledUpdateGroupAction(params).promise().
– jarmod
Jan 1 at 23:33
add a comment |
1 Answer
1
active
oldest
votes
Update:
To ignore any failed promise, using Promise.all(promises).catch()
should catch everything.
Original answer:
If you want to ignore failures of specific promises (not all), you can put a .catch()
handler in each one.
return aws.putScheduledUpdateGroupAction(params).promise().catch((err) => {
// Log the error but don't throw.
console.log(err)
})
Shouldn't thePromise.all
'scatch
handle it though? jsfiddle.net/oLz5bvpa
– CertainPerformance
Jan 2 at 2:04
thanks but I was hoping to fix my existing code before I change the call to.promise()
for the moment
– yoyoma
Jan 2 at 2:57
Promise.all
'scatch
should handle it without the need to put acatch
in each one. Can you share a complete example @yoyoma? If you log the value oferr
in yourputScheduledUpdateGroupAction
handler function do you see anything logged? My guess is the error you are seeing came from somewhere else.
– Jaime
Jan 2 at 16:46
Right.Promise.all
'scatch
catches everything. Clarified it in my answer.
– dashmug
Jan 2 at 23:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f53999499%2fcontinue-promise-all-loop-if-error-caught-in-lambda-node-scenario%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update:
To ignore any failed promise, using Promise.all(promises).catch()
should catch everything.
Original answer:
If you want to ignore failures of specific promises (not all), you can put a .catch()
handler in each one.
return aws.putScheduledUpdateGroupAction(params).promise().catch((err) => {
// Log the error but don't throw.
console.log(err)
})
Shouldn't thePromise.all
'scatch
handle it though? jsfiddle.net/oLz5bvpa
– CertainPerformance
Jan 2 at 2:04
thanks but I was hoping to fix my existing code before I change the call to.promise()
for the moment
– yoyoma
Jan 2 at 2:57
Promise.all
'scatch
should handle it without the need to put acatch
in each one. Can you share a complete example @yoyoma? If you log the value oferr
in yourputScheduledUpdateGroupAction
handler function do you see anything logged? My guess is the error you are seeing came from somewhere else.
– Jaime
Jan 2 at 16:46
Right.Promise.all
'scatch
catches everything. Clarified it in my answer.
– dashmug
Jan 2 at 23:31
add a comment |
Update:
To ignore any failed promise, using Promise.all(promises).catch()
should catch everything.
Original answer:
If you want to ignore failures of specific promises (not all), you can put a .catch()
handler in each one.
return aws.putScheduledUpdateGroupAction(params).promise().catch((err) => {
// Log the error but don't throw.
console.log(err)
})
Shouldn't thePromise.all
'scatch
handle it though? jsfiddle.net/oLz5bvpa
– CertainPerformance
Jan 2 at 2:04
thanks but I was hoping to fix my existing code before I change the call to.promise()
for the moment
– yoyoma
Jan 2 at 2:57
Promise.all
'scatch
should handle it without the need to put acatch
in each one. Can you share a complete example @yoyoma? If you log the value oferr
in yourputScheduledUpdateGroupAction
handler function do you see anything logged? My guess is the error you are seeing came from somewhere else.
– Jaime
Jan 2 at 16:46
Right.Promise.all
'scatch
catches everything. Clarified it in my answer.
– dashmug
Jan 2 at 23:31
add a comment |
Update:
To ignore any failed promise, using Promise.all(promises).catch()
should catch everything.
Original answer:
If you want to ignore failures of specific promises (not all), you can put a .catch()
handler in each one.
return aws.putScheduledUpdateGroupAction(params).promise().catch((err) => {
// Log the error but don't throw.
console.log(err)
})
Update:
To ignore any failed promise, using Promise.all(promises).catch()
should catch everything.
Original answer:
If you want to ignore failures of specific promises (not all), you can put a .catch()
handler in each one.
return aws.putScheduledUpdateGroupAction(params).promise().catch((err) => {
// Log the error but don't throw.
console.log(err)
})
edited Jan 2 at 23:30
answered Jan 1 at 23:52
dashmugdashmug
6,7091942
6,7091942
Shouldn't thePromise.all
'scatch
handle it though? jsfiddle.net/oLz5bvpa
– CertainPerformance
Jan 2 at 2:04
thanks but I was hoping to fix my existing code before I change the call to.promise()
for the moment
– yoyoma
Jan 2 at 2:57
Promise.all
'scatch
should handle it without the need to put acatch
in each one. Can you share a complete example @yoyoma? If you log the value oferr
in yourputScheduledUpdateGroupAction
handler function do you see anything logged? My guess is the error you are seeing came from somewhere else.
– Jaime
Jan 2 at 16:46
Right.Promise.all
'scatch
catches everything. Clarified it in my answer.
– dashmug
Jan 2 at 23:31
add a comment |
Shouldn't thePromise.all
'scatch
handle it though? jsfiddle.net/oLz5bvpa
– CertainPerformance
Jan 2 at 2:04
thanks but I was hoping to fix my existing code before I change the call to.promise()
for the moment
– yoyoma
Jan 2 at 2:57
Promise.all
'scatch
should handle it without the need to put acatch
in each one. Can you share a complete example @yoyoma? If you log the value oferr
in yourputScheduledUpdateGroupAction
handler function do you see anything logged? My guess is the error you are seeing came from somewhere else.
– Jaime
Jan 2 at 16:46
Right.Promise.all
'scatch
catches everything. Clarified it in my answer.
– dashmug
Jan 2 at 23:31
Shouldn't the
Promise.all
's catch
handle it though? jsfiddle.net/oLz5bvpa– CertainPerformance
Jan 2 at 2:04
Shouldn't the
Promise.all
's catch
handle it though? jsfiddle.net/oLz5bvpa– CertainPerformance
Jan 2 at 2:04
thanks but I was hoping to fix my existing code before I change the call to
.promise()
for the moment– yoyoma
Jan 2 at 2:57
thanks but I was hoping to fix my existing code before I change the call to
.promise()
for the moment– yoyoma
Jan 2 at 2:57
Promise.all
's catch
should handle it without the need to put a catch
in each one. Can you share a complete example @yoyoma? If you log the value of err
in your putScheduledUpdateGroupAction
handler function do you see anything logged? My guess is the error you are seeing came from somewhere else.– Jaime
Jan 2 at 16:46
Promise.all
's catch
should handle it without the need to put a catch
in each one. Can you share a complete example @yoyoma? If you log the value of err
in your putScheduledUpdateGroupAction
handler function do you see anything logged? My guess is the error you are seeing came from somewhere else.– Jaime
Jan 2 at 16:46
Right.
Promise.all
's catch
catches everything. Clarified it in my answer.– dashmug
Jan 2 at 23:31
Right.
Promise.all
's catch
catches everything. Clarified it in my answer.– dashmug
Jan 2 at 23:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f53999499%2fcontinue-promise-all-loop-if-error-caught-in-lambda-node-scenario%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
Can you post a Minimal, Complete, and Verifiable example? Where does the error get thrown, exactly?
– CertainPerformance
Jan 1 at 22:40
@CertainPerformance I've added code for the promise created
– yoyoma
Jan 1 at 22:58
You should use the promisified variant of the AWS call. Simply return aws.putScheduledUpdateGroupAction(params).promise().
– jarmod
Jan 1 at 23:33