@workglow/tasks 0.2.13 → 0.2.14
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/bun.js +17 -9
- package/dist/bun.js.map +5 -5
- package/dist/electron.js +17 -9
- package/dist/electron.js.map +5 -5
- package/dist/node.js +17 -9
- package/dist/node.js.map +5 -5
- package/dist/util/SafeFetch.server.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/node.js
CHANGED
|
@@ -263,6 +263,9 @@ import { PermanentJobError as PermanentJobError2 } from "@workglow/job-queue";
|
|
|
263
263
|
import { lookup as dnsLookup } from "node:dns/promises";
|
|
264
264
|
import { Agent, fetch as undiciFetch } from "undici";
|
|
265
265
|
|
|
266
|
+
// src/util/SafeFetch.ts
|
|
267
|
+
import { PermanentJobError } from "@workglow/job-queue";
|
|
268
|
+
|
|
266
269
|
// src/util/UrlClassifier.ts
|
|
267
270
|
import { resourcePatternMatches } from "@workglow/task-graph";
|
|
268
271
|
import ipaddr from "ipaddr.js";
|
|
@@ -491,7 +494,6 @@ function urlMatchesScope(url, patterns) {
|
|
|
491
494
|
}
|
|
492
495
|
|
|
493
496
|
// src/util/SafeFetch.ts
|
|
494
|
-
import { PermanentJobError } from "@workglow/job-queue";
|
|
495
497
|
var MAX_REDIRECT_HOPS = 20;
|
|
496
498
|
function assertAllowedUrl(url, allowPrivate, privateResourceScopes) {
|
|
497
499
|
const classification = classifyUrl(url);
|
|
@@ -555,6 +557,12 @@ function safeFetch(url, options = {}) {
|
|
|
555
557
|
|
|
556
558
|
// src/util/SafeFetch.server.ts
|
|
557
559
|
var MAX_REDIRECT_HOPS2 = 20;
|
|
560
|
+
function closeAgent(dispatcher) {
|
|
561
|
+
dispatcher.close?.().catch(() => {});
|
|
562
|
+
}
|
|
563
|
+
async function closeAgentAsync(dispatcher) {
|
|
564
|
+
await dispatcher.close?.().catch(() => {});
|
|
565
|
+
}
|
|
558
566
|
async function resolveAll(hostname) {
|
|
559
567
|
try {
|
|
560
568
|
const addrs = await dnsLookup(hostname, { all: true, verbatim: true });
|
|
@@ -626,7 +634,7 @@ async function fetchOneHop(url, opts, fetchInit) {
|
|
|
626
634
|
});
|
|
627
635
|
return { response, dispatcher };
|
|
628
636
|
} catch (err) {
|
|
629
|
-
await dispatcher
|
|
637
|
+
await closeAgentAsync(dispatcher);
|
|
630
638
|
throw err;
|
|
631
639
|
}
|
|
632
640
|
}
|
|
@@ -644,14 +652,14 @@ var serverSafeFetch = async (url, options) => {
|
|
|
644
652
|
for (let hops = 0;hops <= MAX_REDIRECT_HOPS2; hops += 1) {
|
|
645
653
|
const { response, dispatcher } = await fetchOneHop(currentUrl, opts, fetchInit);
|
|
646
654
|
if (prevDispatcher !== undefined) {
|
|
647
|
-
prevDispatcher
|
|
655
|
+
closeAgent(prevDispatcher);
|
|
648
656
|
}
|
|
649
657
|
if (!isRedirectStatus2(response.status)) {
|
|
650
658
|
const body = response.body;
|
|
651
659
|
if (body !== null) {
|
|
652
660
|
const { readable, writable } = new TransformStream;
|
|
653
661
|
body.pipeTo(writable).finally(() => {
|
|
654
|
-
dispatcher
|
|
662
|
+
closeAgent(dispatcher);
|
|
655
663
|
});
|
|
656
664
|
return new Response(readable, {
|
|
657
665
|
status: response.status,
|
|
@@ -659,20 +667,20 @@ var serverSafeFetch = async (url, options) => {
|
|
|
659
667
|
headers: response.headers
|
|
660
668
|
});
|
|
661
669
|
}
|
|
662
|
-
dispatcher
|
|
670
|
+
closeAgent(dispatcher);
|
|
663
671
|
return response;
|
|
664
672
|
}
|
|
665
673
|
if (requestedRedirectMode === "manual") {
|
|
666
|
-
dispatcher
|
|
674
|
+
closeAgent(dispatcher);
|
|
667
675
|
return response;
|
|
668
676
|
}
|
|
669
677
|
if (requestedRedirectMode === "error") {
|
|
670
|
-
dispatcher
|
|
678
|
+
closeAgent(dispatcher);
|
|
671
679
|
throw new TypeError(`Fetch for ${currentUrl} failed because redirect mode was set to 'error'.`);
|
|
672
680
|
}
|
|
673
681
|
const location = response.headers.get("location");
|
|
674
682
|
if (!location) {
|
|
675
|
-
dispatcher
|
|
683
|
+
closeAgent(dispatcher);
|
|
676
684
|
throw new PermanentJobError2(`Refusing to follow redirect from ${currentUrl}: missing Location header.`);
|
|
677
685
|
}
|
|
678
686
|
prevDispatcher = dispatcher;
|
|
@@ -16295,4 +16303,4 @@ export {
|
|
|
16295
16303
|
ArrayTask
|
|
16296
16304
|
};
|
|
16297
16305
|
|
|
16298
|
-
//# debugId=
|
|
16306
|
+
//# debugId=3F14772045E1F99364756E2164756E21
|