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

App crash due to unhandled promise rejection in Gus.getWorkItemIdByName #161

Open
mpsenn opened this issue Feb 20, 2023 · 0 comments
Open

Comments

@mpsenn
Copy link
Contributor

mpsenn commented Feb 20, 2023

This TypeError is unhandled, causes a promise to reject, and crashes the app. This function looks like it doesn't really understand Promises either, since it mixes callback functions and async/await.

Wishlist:

  1. Fix the app crash.
  2. Refactor this class to correctly use Promises.
  3. Install a global unhandledpromiserejection logger? Not sure if we want these to lead to app crashes, or just error logs.
TypeError: Cannot read properties of undefined (reading 'Id')
    at /app/api/services/Gus/getWorkItemIdByName.js:29:31
    at promiseCallback (/app/node_modules/jsforce/lib/query.js:337:15)
    at module.exports.<anonymous> (/app/node_modules/jsforce/lib/query.js:350:5)
    at Object.onceWrapper (node:events:510:26)
    at module.exports.emit (node:events:390:28)
    at module.exports.<anonymous> (/app/node_modules/jsforce/lib/query.js:369:14)
    at Object.onceWrapper (node:events:509:28)
    at module.exports.emit (node:events:390:28)
    at endReadableNT (/app/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
mpsenn pushed a commit that referenced this issue Feb 26, 2023
While setting up the staging environment, I made these changes. Some are strictly necessary, like the namespace prefixing on fields. Some helped me find those issues, like returning errors from event handlers and logging more details in createWorkItem.

### Medium changes

(connection.js and services/Gus/*) Keep GUS api sessions alive for 10 minutes. And add debug logging for SOQL requests

(connection.js) Implement namespace prefixes on objects and fields. This should have been implemented when the app started supporting Agile Accelerator, which always has a namespace; not sure why this wasn't done already.

(GithubEvents/index.js and ghEvents.js) Wait for event handlers to return before returning from the github webhook. Previously webhooks would return synchronously, before any GUS callouts would be processed. Now, GUS callouts will delay the webhook response and can affect the 2xx/5xx status code. This will help track errors and latency through logs.

### Small changes

Add missing peer dependency 'winston'

Add logs in createWorkItem that helped diagnose an issue with bug priorities.

(GithubEvents/index.js) Use captureRejectionSymbol to mitigate an unhandled promise rejection and avoid app crash. Related to #161.
mpsenn pushed a commit that referenced this issue Mar 1, 2023
Fixes #165. While setting up the staging environment, I made these changes. Some are strictly necessary, like the namespace prefixing on fields. Some helped me find those issues, like returning errors from event handlers and logging more details in createWorkItem.

**Medium changes**

(connection.js and services/Gus/*) Keep GUS api sessions alive for 10 minutes. And add debug logging for SOQL requests

(connection.js) Implement namespace prefixes on objects and fields. This should have been implemented when the app started supporting Agile Accelerator, which always has a namespace; not sure why this wasn't done already.

(GithubEvents/index.js and ghEvents.js) Wait for event handlers to return before returning from the github webhook. Previously webhooks would return synchronously, before any GUS callouts would be processed. Now, GUS callouts will delay the webhook response and can affect the 2xx/5xx status code. This will help track errors and latency through logs.

**Small changes**

Add missing peer dependency 'winston'

Add logs in createWorkItem that helped diagnose an issue with bug priorities.

(GithubEvents/index.js) Use captureRejectionSymbol to mitigate an unhandled promise rejection and avoid app crash. Related to #161.
mpsenn pushed a commit that referenced this issue Mar 1, 2023
Fixes #165. While setting up the staging environment, I made these changes. Some are strictly necessary, like the namespace prefixing on fields. Some helped me find those issues, like returning errors from event handlers and logging more details in createWorkItem.

**Medium changes**

(connection.js and services/Gus/*) Keep GUS api sessions alive for 10 minutes. And add debug logging for SOQL requests

(connection.js) Implement namespace prefixes on objects and fields. This should have been implemented when the app started supporting Agile Accelerator, which always has a namespace; not sure why this wasn't done already.

(GithubEvents/index.js and ghEvents.js) Wait for event handlers to return before returning from the github webhook. Previously webhooks would return synchronously, before any GUS callouts would be processed. Now, GUS callouts will delay the webhook response and can affect the 2xx/5xx status code. This will help track errors and latency through logs.

**Small changes**

Add missing peer dependency 'winston'

Add logs in createWorkItem that helped diagnose an issue with bug priorities.

(GithubEvents/index.js) Use captureRejectionSymbol to mitigate an unhandled promise rejection and avoid app crash. Related to #161.
mpsenn pushed a commit that referenced this issue Apr 5, 2023
* Changes to get staging environment working

Fixes #165. While setting up the staging environment, I made these changes. Some are strictly necessary, like the namespace prefixing on fields. Some helped me find those issues, like returning errors from event handlers and logging more details in createWorkItem.

**Medium changes**

(connection.js and services/Gus/*) Keep GUS api sessions alive for 10 minutes. And add debug logging for SOQL requests

(connection.js) Implement namespace prefixes on objects and fields. This should have been implemented when the app started supporting Agile Accelerator, which always has a namespace; not sure why this wasn't done already.

(GithubEvents/index.js and ghEvents.js) Wait for event handlers to return before returning from the github webhook. Previously webhooks would return synchronously, before any GUS callouts would be processed. Now, GUS callouts will delay the webhook response and can affect the 2xx/5xx status code. This will help track errors and latency through logs.

**Small changes**

Add missing peer dependency 'winston'

Add logs in createWorkItem that helped diagnose an issue with bug priorities.

(GithubEvents/index.js) Use captureRejectionSymbol to mitigate an unhandled promise rejection and avoid app crash. Related to #161.

* prettier rules say single quotes

* use jsforce auto-refresh

Also log and throw all rejections from handlers
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

No branches or pull requests

1 participant