@whatwg-node/node-fetch
Advanced tools
Comparing version 0.7.5 to 0.8.0-alpha-20241212150911-36df5929a304522e501744daf167032d4b7994c0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PonyfillAbortError = void 0; | ||
class PonyfillAbortError extends Error { | ||
class PonyfillAbortError extends DOMException { | ||
constructor(reason) { | ||
@@ -10,6 +10,4 @@ let message = 'The operation was aborted'; | ||
} | ||
super(message, { | ||
cause: reason, | ||
}); | ||
this.name = 'AbortError'; | ||
super(message, 'AbortError'); | ||
this.cause = reason; | ||
} | ||
@@ -16,0 +14,0 @@ get reason() { |
@@ -115,2 +115,19 @@ "use strict"; | ||
.catch(deferredPromise.reject); | ||
if (fetchRequest['_signal']) { | ||
outputStream.once('error', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('close', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('destroy', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
} | ||
const headersFlat = headersBuf | ||
@@ -117,0 +134,0 @@ .toString('utf8') |
@@ -111,2 +111,19 @@ "use strict"; | ||
.catch(reject); | ||
if (fetchRequest['_signal']) { | ||
outputStream.once('error', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('close', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('destroy', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
} | ||
const ponyfillResponse = new Response_js_1.PonyfillResponse(outputStream, { | ||
@@ -113,0 +130,0 @@ status: nodeResponse.statusCode, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TextEncoderStream = exports.TextDecoderStream = exports.IteratorObject = exports.DecompressionStream = exports.CompressionStream = exports.TransformStream = exports.WritableStream = exports.URLSearchParams = exports.URL = exports.btoa = exports.TextDecoder = exports.TextEncoder = exports.Blob = exports.FormData = exports.File = exports.ReadableStream = exports.Response = exports.Request = exports.Body = exports.Headers = exports.fetch = void 0; | ||
exports.AbortError = exports.AbortSignal = exports.AbortController = exports.TextEncoderStream = exports.TextDecoderStream = exports.IteratorObject = exports.DecompressionStream = exports.CompressionStream = exports.TransformStream = exports.WritableStream = exports.URLSearchParams = exports.URL = exports.btoa = exports.TextDecoder = exports.TextEncoder = exports.Blob = exports.FormData = exports.File = exports.ReadableStream = exports.Response = exports.Request = exports.Body = exports.Headers = exports.fetch = void 0; | ||
var fetch_js_1 = require("./fetch.js"); | ||
@@ -43,1 +43,7 @@ Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_js_1.fetchPonyfill; } }); | ||
Object.defineProperty(exports, "TextEncoderStream", { enumerable: true, get: function () { return TextEncoderDecoderStream_js_1.PonyfillTextEncoderStream; } }); | ||
var AbortController_js_1 = require("./AbortController.js"); | ||
Object.defineProperty(exports, "AbortController", { enumerable: true, get: function () { return AbortController_js_1.PonyfillAbortController; } }); | ||
var AbortSignal_js_1 = require("./AbortSignal.js"); | ||
Object.defineProperty(exports, "AbortSignal", { enumerable: true, get: function () { return AbortSignal_js_1.PonyfillAbortSignal; } }); | ||
var AbortError_js_1 = require("./AbortError.js"); | ||
Object.defineProperty(exports, "AbortError", { enumerable: true, get: function () { return AbortError_js_1.PonyfillAbortError; } }); |
@@ -6,2 +6,3 @@ "use strict"; | ||
const https_1 = require("https"); | ||
const AbortController_js_1 = require("./AbortController.js"); | ||
const Body_js_1 = require("./Body.js"); | ||
@@ -126,3 +127,3 @@ const Headers_js_1 = require("./Headers.js"); | ||
if (!this._signal) { | ||
this._signal = new AbortController().signal; | ||
this._signal = new AbortController_js_1.PonyfillAbortController().signal; | ||
} | ||
@@ -129,0 +130,0 @@ return this._signal; |
@@ -1,2 +0,2 @@ | ||
export class PonyfillAbortError extends Error { | ||
export class PonyfillAbortError extends DOMException { | ||
constructor(reason) { | ||
@@ -7,6 +7,4 @@ let message = 'The operation was aborted'; | ||
} | ||
super(message, { | ||
cause: reason, | ||
}); | ||
this.name = 'AbortError'; | ||
super(message, 'AbortError'); | ||
this.cause = reason; | ||
} | ||
@@ -13,0 +11,0 @@ get reason() { |
@@ -112,2 +112,19 @@ import { PassThrough, Readable, promises as streamPromises } from 'stream'; | ||
.catch(deferredPromise.reject); | ||
if (fetchRequest['_signal']) { | ||
outputStream.once('error', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('close', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('destroy', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
} | ||
const headersFlat = headersBuf | ||
@@ -114,0 +131,0 @@ .toString('utf8') |
@@ -108,2 +108,19 @@ import { request as httpRequest } from 'http'; | ||
.catch(reject); | ||
if (fetchRequest['_signal']) { | ||
outputStream.once('error', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('close', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
outputStream.once('destroy', () => { | ||
if (!fetchRequest['_signal']?.aborted) { | ||
fetchRequest['_signal']?.sendAbort?.(); | ||
} | ||
}); | ||
} | ||
const ponyfillResponse = new PonyfillResponse(outputStream, { | ||
@@ -110,0 +127,0 @@ status: nodeResponse.statusCode, |
@@ -19,1 +19,4 @@ export { fetchPonyfill as fetch } from './fetch.js'; | ||
export { PonyfillTextDecoderStream as TextDecoderStream, PonyfillTextEncoderStream as TextEncoderStream, } from './TextEncoderDecoderStream.js'; | ||
export { PonyfillAbortController as AbortController } from './AbortController.js'; | ||
export { PonyfillAbortSignal as AbortSignal } from './AbortSignal.js'; | ||
export { PonyfillAbortError as AbortError } from './AbortError.js'; |
import { Agent as HTTPAgent } from 'http'; | ||
import { Agent as HTTPSAgent } from 'https'; | ||
import { PonyfillAbortController } from './AbortController.js'; | ||
import { PonyfillBody } from './Body.js'; | ||
@@ -122,3 +123,3 @@ import { isHeadersLike, PonyfillHeaders } from './Headers.js'; | ||
if (!this._signal) { | ||
this._signal = new AbortController().signal; | ||
this._signal = new PonyfillAbortController().signal; | ||
} | ||
@@ -125,0 +126,0 @@ return this._signal; |
{ | ||
"name": "@whatwg-node/node-fetch", | ||
"version": "0.7.5", | ||
"version": "0.8.0-alpha-20241212150911-36df5929a304522e501744daf167032d4b7994c0", | ||
"description": "Fetch API implementation for Node", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -1,4 +0,4 @@ | ||
export declare class PonyfillAbortError extends Error { | ||
export declare class PonyfillAbortError extends DOMException { | ||
constructor(reason?: any); | ||
get reason(): unknown; | ||
} |
@@ -19,1 +19,4 @@ export { fetchPonyfill as fetch } from './fetch.js'; | ||
export { PonyfillTextDecoderStream as TextDecoderStream, PonyfillTextEncoderStream as TextEncoderStream, } from './TextEncoderDecoderStream.js'; | ||
export { PonyfillAbortController as AbortController } from './AbortController.js'; | ||
export { PonyfillAbortSignal as AbortSignal } from './AbortSignal.js'; | ||
export { PonyfillAbortError as AbortError } from './AbortError.js'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
247104
102
6257