@durable-streams/client 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -147,7 +147,7 @@ var FetchError = class FetchError extends Error {
147
147
  let text = void 0;
148
148
  let json = void 0;
149
149
  const contentType = response.headers.get(`content-type`);
150
- if (!response.bodyUsed) if (contentType && contentType.includes(`application/json`)) try {
150
+ if (!response.bodyUsed && response.body !== null) if (contentType && contentType.includes(`application/json`)) try {
151
151
  json = await response.json();
152
152
  } catch {
153
153
  text = await response.text();
@@ -196,7 +196,7 @@ var DurableStreamError = class DurableStreamError extends Error {
196
196
  const status = response.status;
197
197
  let details;
198
198
  const contentType = response.headers.get(`content-type`);
199
- if (!response.bodyUsed) if (contentType && contentType.includes(`application/json`)) try {
199
+ if (!response.bodyUsed && response.body !== null) if (contentType && contentType.includes(`application/json`)) try {
200
200
  details = await response.json();
201
201
  } catch {
202
202
  details = await response.text();
package/dist/index.js CHANGED
@@ -123,7 +123,7 @@ var FetchError = class FetchError extends Error {
123
123
  let text = void 0;
124
124
  let json = void 0;
125
125
  const contentType = response.headers.get(`content-type`);
126
- if (!response.bodyUsed) if (contentType && contentType.includes(`application/json`)) try {
126
+ if (!response.bodyUsed && response.body !== null) if (contentType && contentType.includes(`application/json`)) try {
127
127
  json = await response.json();
128
128
  } catch {
129
129
  text = await response.text();
@@ -172,7 +172,7 @@ var DurableStreamError = class DurableStreamError extends Error {
172
172
  const status = response.status;
173
173
  let details;
174
174
  const contentType = response.headers.get(`content-type`);
175
- if (!response.bodyUsed) if (contentType && contentType.includes(`application/json`)) try {
175
+ if (!response.bodyUsed && response.body !== null) if (contentType && contentType.includes(`application/json`)) try {
176
176
  details = await response.json();
177
177
  } catch {
178
178
  details = await response.text();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@durable-streams/client",
3
3
  "description": "TypeScript client for the Durable Streams protocol",
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
5
5
  "author": "Durable Stream contributors",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -54,7 +54,7 @@
54
54
  "@tanstack/intent": "latest",
55
55
  "fast-check": "^4.4.0",
56
56
  "tsdown": "^0.9.0",
57
- "@durable-streams/server": "0.2.2"
57
+ "@durable-streams/server": "0.2.3"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">=18.0.0"
package/src/error.ts CHANGED
@@ -39,7 +39,7 @@ export class FetchError extends Error {
39
39
  let json: object | undefined = undefined
40
40
 
41
41
  const contentType = response.headers.get(`content-type`)
42
- if (!response.bodyUsed) {
42
+ if (!response.bodyUsed && response.body !== null) {
43
43
  if (contentType && contentType.includes(`application/json`)) {
44
44
  try {
45
45
  json = (await response.json()) as object
@@ -110,7 +110,7 @@ export class DurableStreamError extends Error {
110
110
  let details: unknown
111
111
 
112
112
  const contentType = response.headers.get(`content-type`)
113
- if (!response.bodyUsed) {
113
+ if (!response.bodyUsed && response.body !== null) {
114
114
  if (contentType && contentType.includes(`application/json`)) {
115
115
  try {
116
116
  details = await response.json()