Skip to content

Commit 88b1877

Browse files
authored
fix(api): add duplex configuration to fetch (#19)
Node sneakily introduced a change to the fetch API that now requires that the `duplex` option be set on all requests with contain a payload body: nodejs/node#46221 , which means that the CLI now fails on node >18.13, >19.1, 20, and running the CLI on those versions will cause the following exception: ``` RequestInit: duplex option is required when sending a body. Exited with code exit status 1 ``` This configures all fetch requests with bodies to set the duplex option to the only value that is allowed by the spec for now, which is `"half"`. This should have no impact on older node versions since it's the only option available, but will allow the CLI to run on those newer versions without throwing an error.
1 parent 78639d5 commit 88b1877

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/apiClient.js

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ApiClient {
5252
method: 'POST',
5353
headers: this.headers,
5454
body: JSON.stringify(data),
55+
duplex: 'half',
5556
});
5657
}
5758

@@ -110,6 +111,7 @@ class ApiClient {
110111
maxRetryDelay,
111112
method: 'PUT',
112113
body: contents,
114+
duplex: 'half',
113115
});
114116

115117
if (this._gcsBucket) {
@@ -123,6 +125,7 @@ class ApiClient {
123125
name: fileData.name,
124126
bucket: this._gcsBucket,
125127
}),
128+
duplex: 'half',
126129
});
127130
}
128131

0 commit comments

Comments
 (0)