slackapi / slackapi/node-slack-sdk
web-api v8 no longer retries interrupted response bodies
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.4k
- Forks
- 688
- Avg merge
- 15h 31m
- Merged PRs (30d)
- 27
Description
Package
@slack/web-api
SDK Version
8.1.1
Node.js Version
24.21.0
Operating System
Microsoft Windows [Version 10.0.26200.9445]
Steps to Reproduce
Run this with each SDK version. The server drops the first response after sending HTTP 200 headers and part of the body, then succeeds on retry.
const http = require('node:http');
const { WebClient } = require('@slack/web-api');
let requests = 0;
const server = http.createServer((req, res) => {
req.resume();
if (++requests === 1) {
res.writeHead(200, { 'Content-Type': 'application/json', 'Content-Length': '100' });
res.write('{"ok":');
setTimeout(() => res.destroy(), 50);
} else {
res.end('{"ok":true}');
}
});
server.listen(0, '127.0.0.1', async () => {
const client = new WebClient('unused', {
slackApiUrl: `http://127.0.0.1:${server.address().port}/`,
retryConfig: { retries: 1, minTimeout: 1, maxTimeout: 1 },
});
try {
console.log(await client.auth.test());
} catch (error) {
console.log(error.name, error.message, error.code);
} finally {
console.log({ requests });
server.closeAllConnections();
server.close();
}
});
Expected Result
The call should retry once and return { ok: true, response_metadata: {} }, with { requests: 2 }, as 7.19.0 does.
The automatic retries docs say "The client will retry a failed API method call up to 10 times"; this repro sets retries: 1. The error-handling docs also say SDK errors have a code property.
Actual Result
With 8.1.1, the repro prints:
TypeError terminated undefined
{ requests: 1 }
auth.test() rejects after the first request without retrying. The error is a raw TypeError, and error.code is undefined.
makeRequest() retries fetch(), but buildResult() reads response.text() outside that retry loop. A disconnect while reading the body therefore skips both retrying and error wrapping.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the @slack/web-api request path, especially makeRequest() and buildResult(), and run the supplied Node.js reproduction against the current version. Trace how a response-body disconnect is handled and compare it with the documented retry and error-code behavior; done means the repro retries once and returns the expected result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100