Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove redundant .then() causing unhandled exception #1671

Merged
merged 3 commits into from
Jan 23, 2023

Conversation

garymathews
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1547 馃

Note: If you are opening a pull request against a legacy branch, PLEASE BE AWARE that we generally won't accept these except for things like important security fixes, and only for a limited time.


I'm not sure why .then() was added here, it appears to be redundant. But without chaining it will cause an unhandled exception; which is causing #1547.

Here's an example of an uncaught exception being thrown when chaining isn't used:

const promise = new Promise((resolve, reject) => {
    reject();
});

promise.then(() => console.log('resolved'));
promise.catch(e => console.error('rejected'));
rejected
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: 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(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

@garymathews garymathews requested review from a team as code owners December 26, 2022 23:42
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: pubsub Issues related to the googleapis/nodejs-pubsub API. labels Dec 26, 2022
phil-booth-qatalog added a commit to qatalog/nodejs-pubsub that referenced this pull request Jan 6, 2023
viniychuk
viniychuk previously approved these changes Jan 16, 2023
Copy link

@viniychuk viniychuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works! Please merge it!

@garymathews
Copy link
Contributor Author

CC @feywind @alexander-fenster @hongalex

I'd say this is a high priority issue, since without an unhandledException handler the app will just terminate upon receiving an error during an ack

feywind
feywind previously approved these changes Jan 23, 2023
@feywind
Copy link
Collaborator

feywind commented Jan 23, 2023

@garymathews Apologies, I've been OoO and I'm the main maintainer. Hopefully we can get this in quickly.

@feywind feywind added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 23, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 23, 2023
@feywind feywind added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 23, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 23, 2023
@feywind feywind added the automerge: exact Summon MOG for automerging, but approvals need to be against the latest commit label Jan 23, 2023
@gcf-merge-on-green gcf-merge-on-green bot dismissed stale reviews from feywind and viniychuk January 23, 2023 20:38

This review does not reference the most recent commit, and you are using the secure version of merge-on-green. Please re-review the most recent commit.

@feywind feywind merged commit 108edc3 into googleapis:main Jan 23, 2023
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge: exact Summon MOG for automerging, but approvals need to be against the latest commit label Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/nodejs-pubsub API. size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Exactly once delivery) BatchError: Failed to "modifyAckDeadline" Reason: 3 INVALID_ARGUMENT.
4 participants