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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: application crash when timeout encountered #569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mmollick
Copy link

I encountered occasional application crashes and traced them back to timeouts coming from the Nylas API. After reviewing the Nylas-SDK, I found the culprit in the setTimeout call used to abort the request. It's bad practice to throw an error from setTimeout as its try...catch blocks will not intercept the error. Instead, these errors will crash the application.

node-fetch will reject when controller.abort() is called, so we don't need to throw from the timeout anyway.

Reference:
https://jaketrent.com/post/catch-error-thrown-settimeout/
https://nodejs.org/dist/latest-v7.x/docs/api/errors.html#errors_node_js_style_callbacks

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant