@continuedev/fetch 1.0.14 → 1.0.16
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/fetch.js +2 -2
- package/dist/fetch.test.js +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/stream.js +7 -1
- package/dist/stream.test.js +1 -1
- package/package.json +1 -1
- package/release.config.js +3 -0
- package/src/fetch.ts +2 -2
- package/src/index.ts +3 -0
- package/src/stream.test.ts +1 -1
- package/src/stream.ts +11 -1
- package/src/node_modules/.vite/vitest/d41d8cd98f00b204e9800998ecf8427e/results.json +0 -1
- package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
package/dist/fetch.js
CHANGED
|
@@ -3,7 +3,7 @@ import { HttpProxyAgent } from "http-proxy-agent";
|
|
|
3
3
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
4
4
|
import { Response } from "node-fetch";
|
|
5
5
|
import { getAgentOptions } from "./getAgentOptions.js";
|
|
6
|
-
import
|
|
6
|
+
import patchedFetch from "./node-fetch-patch.js";
|
|
7
7
|
import { getProxy, shouldBypassProxy } from "./util.js";
|
|
8
8
|
const { http, https } = followRedirects.default;
|
|
9
9
|
function logRequest(method, url, headers, body, proxy, shouldBypass) {
|
|
@@ -112,7 +112,7 @@ export async function fetchwithRequestOptions(url_, init, requestOptions) {
|
|
|
112
112
|
}
|
|
113
113
|
// fetch the request with the provided options
|
|
114
114
|
try {
|
|
115
|
-
const resp = await
|
|
115
|
+
const resp = await patchedFetch(url, {
|
|
116
116
|
...init,
|
|
117
117
|
body: finalBody,
|
|
118
118
|
headers: headers,
|
package/dist/fetch.test.js
CHANGED
|
@@ -2,6 +2,7 @@ import { globalAgent } from "https";
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as os from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
5
|
+
import { afterEach, beforeEach, expect, test } from "vitest";
|
|
5
6
|
import { getAgentOptions } from "./getAgentOptions.js";
|
|
6
7
|
// Store original env
|
|
7
8
|
const originalEnv = process.env;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { streamJSON, streamResponse, streamSse, toAsyncIterable } from "./stream.js";
|
|
2
|
+
import patchedFetch from "./node-fetch-patch.js";
|
|
2
3
|
import { fetchwithRequestOptions } from "./fetch.js";
|
|
3
|
-
export { fetchwithRequestOptions, streamJSON, streamResponse, streamSse, toAsyncIterable, };
|
|
4
|
+
export { fetchwithRequestOptions, patchedFetch, streamJSON, streamResponse, streamSse, toAsyncIterable, };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { streamJSON, streamResponse, streamSse, toAsyncIterable, } from "./stream.js";
|
|
2
|
+
import patchedFetch from "./node-fetch-patch.js";
|
|
2
3
|
import { fetchwithRequestOptions } from "./fetch.js";
|
|
3
|
-
export { fetchwithRequestOptions, streamJSON, streamResponse, streamSse, toAsyncIterable, };
|
|
4
|
+
export { fetchwithRequestOptions, patchedFetch, streamJSON, streamResponse, streamSse, toAsyncIterable, };
|
package/dist/stream.js
CHANGED
|
@@ -67,7 +67,13 @@ export function parseDataLine(line) {
|
|
|
67
67
|
try {
|
|
68
68
|
const data = JSON.parse(json);
|
|
69
69
|
if (data.error) {
|
|
70
|
-
|
|
70
|
+
if (data.error &&
|
|
71
|
+
typeof data.error === "object" &&
|
|
72
|
+
"message" in data.error) {
|
|
73
|
+
console.error("Error in streamed response:", data.error);
|
|
74
|
+
throw new Error(`Error streaming response: ${data.error.message}`);
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`Error streaming response: ${JSON.stringify(data.error)}`);
|
|
71
77
|
}
|
|
72
78
|
return data;
|
|
73
79
|
}
|
package/dist/stream.test.js
CHANGED
|
@@ -69,7 +69,7 @@ describe("parseDataLine", () => {
|
|
|
69
69
|
});
|
|
70
70
|
test("parseDataLine should throw error when data contains error field", () => {
|
|
71
71
|
const line = 'data: {"error":"something went wrong"}';
|
|
72
|
-
expect(() => parseDataLine(line)).toThrow(
|
|
72
|
+
expect(() => parseDataLine(line)).toThrow('Error streaming response: "something went wrong"');
|
|
73
73
|
});
|
|
74
74
|
test("parseDataLine should handle empty objects", () => {
|
|
75
75
|
const line = "data: {}";
|
package/package.json
CHANGED
package/src/fetch.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { HttpProxyAgent } from "http-proxy-agent";
|
|
|
4
4
|
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
5
5
|
import { BodyInit, RequestInit, Response } from "node-fetch";
|
|
6
6
|
import { getAgentOptions } from "./getAgentOptions.js";
|
|
7
|
-
import
|
|
7
|
+
import patchedFetch from "./node-fetch-patch.js";
|
|
8
8
|
import { getProxy, shouldBypassProxy } from "./util.js";
|
|
9
9
|
|
|
10
10
|
const { http, https } = (followRedirects as any).default;
|
|
@@ -144,7 +144,7 @@ export async function fetchwithRequestOptions(
|
|
|
144
144
|
|
|
145
145
|
// fetch the request with the provided options
|
|
146
146
|
try {
|
|
147
|
-
const resp = await
|
|
147
|
+
const resp = await patchedFetch(url, {
|
|
148
148
|
...init,
|
|
149
149
|
body: finalBody,
|
|
150
150
|
headers: headers,
|
package/src/index.ts
CHANGED
|
@@ -5,10 +5,13 @@ import {
|
|
|
5
5
|
toAsyncIterable,
|
|
6
6
|
} from "./stream.js";
|
|
7
7
|
|
|
8
|
+
import patchedFetch from "./node-fetch-patch.js";
|
|
9
|
+
|
|
8
10
|
import { fetchwithRequestOptions } from "./fetch.js";
|
|
9
11
|
|
|
10
12
|
export {
|
|
11
13
|
fetchwithRequestOptions,
|
|
14
|
+
patchedFetch,
|
|
12
15
|
streamJSON,
|
|
13
16
|
streamResponse,
|
|
14
17
|
streamSse,
|
package/src/stream.test.ts
CHANGED
|
@@ -86,7 +86,7 @@ describe("parseDataLine", () => {
|
|
|
86
86
|
test("parseDataLine should throw error when data contains error field", () => {
|
|
87
87
|
const line = 'data: {"error":"something went wrong"}';
|
|
88
88
|
expect(() => parseDataLine(line)).toThrow(
|
|
89
|
-
|
|
89
|
+
'Error streaming response: "something went wrong"',
|
|
90
90
|
);
|
|
91
91
|
});
|
|
92
92
|
|
package/src/stream.ts
CHANGED
|
@@ -81,7 +81,17 @@ export function parseDataLine(line: string): any {
|
|
|
81
81
|
try {
|
|
82
82
|
const data = JSON.parse(json);
|
|
83
83
|
if (data.error) {
|
|
84
|
-
|
|
84
|
+
if (
|
|
85
|
+
data.error &&
|
|
86
|
+
typeof data.error === "object" &&
|
|
87
|
+
"message" in data.error
|
|
88
|
+
) {
|
|
89
|
+
console.error("Error in streamed response:", data.error);
|
|
90
|
+
throw new Error(`Error streaming response: ${data.error.message}`);
|
|
91
|
+
}
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Error streaming response: ${JSON.stringify(data.error)}`,
|
|
94
|
+
);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
return data;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"3.2.0","results":[[":node-fetch-bug.test.ts",{"duration":10.538165999999933,"failed":true}],[":boundary-assumption.test.ts",{"duration":392.1355840000324,"failed":false}],[":chunk-transformer.test.ts",{"duration":0,"failed":true}],[":fetch.test.ts",{"duration":115.30825000000186,"failed":false}],[":getAgentOptions.test.ts",{"duration":6.5474579999936395,"failed":false}],[":stream.test.ts",{"duration":68.50500000000466,"failed":false}],[":premature-close.test.ts",{"duration":5329.249708,"failed":true}],[":util.test.ts",{"duration":3.016583999999966,"failed":false}]]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"3.2.1","results":[[":node-fetch-patch.test.ts",{"duration":125.8410000000149,"failed":true}],[":remove/node-fetch-patch.test.ts",{"duration":214.92558300006203,"failed":true}],[":patch-test.test.js",{"duration":1.4479579999999999,"failed":false}],[":premature-close.test.ts",{"duration":5396.810541999992,"failed":true}],[":util.test.ts",{"duration":4.095832999795675,"failed":false}]]}
|