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

Add support for AbortSignal

Open LinusU opened this issue 2 months ago • 5 comments

Summary

This adds support for aborting in-flight requests, using the standardized AbortSignal

Fixes #1761

I've designed this as an additional parameter instead of mixing it with the body of the specific endpoint. I believe that this is a sounder approach as there will never be any conflicts, and it also avoids the current problem of token also being present in the request body as well as in the header when specified this way.

Requirements (place an x in each [ ])

LinusU avatar Oct 08 '25 09:10 LinusU

Thanks for the contribution! Before we can merge this, we need @LinusU to sign the Salesforce Inc. Contributor License Agreement.

salesforce-cla[bot] avatar Oct 08 '25 09:10 salesforce-cla[bot]

@salesforce-cla signed ✅

LinusU avatar Oct 08 '25 09:10 LinusU

Hey @LinusU! 👋 Thanks so much for sending this contribution in 👾 ✨

At the moment we're exploring another approach of a custom fetch attribute as an option to the WebClient alongside efforts of #2359.

I don't have more to share for @slack/web-api at the moment, but an example from @slack/webhook might resemble:

https://github.com/slackapi/node-slack-sdk/blob/56a6183f91437c75fc414fad81d26011d70f2ff5/packages/webhook/README.md?plain=1#L95-L133

Let's keep this open while that's explored, but I'm curious if the fetch approach might also be suitable for you?

zimeg avatar Oct 16 '25 02:10 zimeg

Hey @zimeg, thanks for taking a look at this! 👋

[...] but I'm curious if the fetch approach might also be suitable for you?

I would love for this package to be based on fetch instead of Aaxios, and I took special care when writing this to not expose any Axios-specific behaviour (e.g. that is why I do the little dance to throw the correct error, instead of the Axios-specific cancelled error). So this should pair up great together with the fetch move!

With that said, I do not think that being able to pass in a custom fetch-function would solve the problem here. We are using AbortSignals across large parts of our app, not just as a tool to set a specific timeout on http requests.

I need to be able to pass signal individually to each api call, not at the creation of WebClient.


Side note: the example you linked will cancel every single request made 400 milliseconds after the ProxyAgent was constructed, not after each request has ran for 400ms?

LinusU avatar Oct 16 '25 10:10 LinusU

ping @zimeg, have you had a chance to read my last comment? 🙏

LinusU avatar Nov 10 '25 15:11 LinusU