node-slack-sdk icon indicating copy to clipboard operation
node-slack-sdk copied to clipboard

Append original stack when WebClient#apiCall throws

Open oleg-codaio opened this issue 5 years ago • 3 comments

Summary

When an API call within @slack/web-api fails, the resulting error's stack loses the call context:

Error: An API error occurred: account_inactive
     at Object.platformErrorFromResult (/project/node_modules/@slack/web-api/src/errors.ts:94:5)
     at WebClient.apiCall (/project/node_modules/@slack/web-api/src/WebClient.ts:188:13)
     at runMicrotasks (<anonymous>)
     at processTicksAndRejections (internal/process/task_queues.js:97:5)

This PR appends the original stack leading up to the call so that developers can more easily trace failing calls.

For more details, see https://github.com/slackapi/node-slack-sdk/issues/561#issuecomment-679265974

Requirements (place an x in each [ ])

oleg-codaio avatar Aug 24 '20 17:08 oleg-codaio

Codecov Report

Merging #1086 into main will increase coverage by 0.02%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1086      +/-   ##
==========================================
+ Coverage   94.34%   94.37%   +0.02%     
==========================================
  Files          12       12              
  Lines         796      800       +4     
  Branches      177      177              
==========================================
+ Hits          751      755       +4     
  Misses         15       15              
  Partials       30       30              
Flag Coverage Δ
#eventsapi 90.74% <ø> (ø)
#interactivemessages 94.83% <ø> (ø)
#webapi 95.63% <ø> (+0.05%) :arrow_up:
#webhook 87.50% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/WebClient.ts 94.05% <0.00%> (+0.12%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update caa1fd0...c272377. Read the comment docs.

codecov[bot] avatar Aug 25 '20 09:08 codecov[bot]

Hey @vaskevich!

Thanks for sending this in.

Ended up commenting on the issue to continue discussion

stevengill avatar Sep 03 '20 18:09 stevengill

This would really improve the developer experience. Currently, errors thrown by the web client are only referencing the stack as they know it when the promise is being resolved. This means we often cannot determine the source of the error without painstaking debugging and isolation steps.

jaywhiletwo avatar Jun 27 '23 00:06 jaywhiletwo