commercetools / commercetools/nodejs

Unhandled Promise Rejections coming from sdk-middleware-http

Open
#1,858 1 comment 1 reaction 1 assignee Claimed by @ajimae View on GitHub
Type: Bug
Dominant language
JavaScript
Stars
77
Forks
70
PR merge metrics
No merged PRs in 30d

Description

### Description

There is no promise rejection handling around the conversion of a HTTP response to text with [`res.text()`](https://github.com/commercetools/nodejs/blob/master/packages/sdk-middleware-http/src/http.js#LL194C17-L194C27) in `sdk-middleware-http`. This causes an unhandled promise rejection when that call fails.

The route cause for this rejection is an issuing in the version of node we are using, in how chunked HTTP responses are handled with `node-fetch`. https://github.com/node-fetch/node-fetch/issues/1219

A rather hard error to replicate, but it's to do with a "Premature Close" happening when reading from response body in the call to `res.text()`.

### Expected Behavior

The normal error handling happens. So retries if applicable, etc.

### Current Behavior

A unhandled promise rejection happens, crashing the process in Node 16+

### Context

~50 unhandled promise rejection per day.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.