slackapi / slackapi/node-slack-sdk

web-api v8 no longer retries interrupted response bodies

Open
#2,738 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triage-skip bug pkg:web-api semver:patch
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.