code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
get onopen() {
return __privateGet(this, _events).open;
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
onopen
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
set onopen(fn) {
if (__privateGet(this, _events).open) {
this.removeEventListener("open", __privateGet(this, _events).open);
}
if (typeof fn === "function") {
__privateGet(this, _events).open = fn;
this.addEventListener("open", fn);
} else {
__privateGet(this, _events).open = null;
}
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
onopen
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
get onmessage() {
return __privateGet(this, _events).message;
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
onmessage
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
set onmessage(fn) {
if (__privateGet(this, _events).message) {
this.removeEventListener("message", __privateGet(this, _events).message);
}
if (typeof fn === "function") {
__privateGet(this, _events).message = fn;
this.addEventListener("message", fn);
} else {
__privateGet(this, _events).message = null;
}
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
onmessage
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
get onerror() {
return __privateGet(this, _events).error;
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
onerror
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
set onerror(fn) {
if (__privateGet(this, _events).error) {
this.removeEventListener("error", __privateGet(this, _events).error);
}
if (typeof fn === "function") {
__privateGet(this, _events).error = fn;
this.addEventListener("error", fn);
} else {
__privateGet(this, _events).error = null;
}
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
onerror
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
function makeDispatcher(fn) {
return (url, opts, handler) => {
if (typeof opts === "function") {
handler = opts;
opts = null;
}
if (!url || typeof url !== "string" && typeof url !== "object" && !(url instanceof URL)) {
throw new InvalidArgumentError("invalid url");
}
if (opts != null && typeof opts !== "object") {
throw new InvalidArgumentError("invalid opts");
}
if (opts && opts.path != null) {
if (typeof opts.path !== "string") {
throw new InvalidArgumentError("invalid opts.path");
}
let path = opts.path;
if (!opts.path.startsWith("/")) {
path = `/${path}`;
}
url = new URL(util.parseOrigin(url).origin + path);
} else {
if (!opts) {
opts = typeof url === "object" ? url : {};
}
url = util.parseURL(url);
}
const { agent, dispatcher = getGlobalDispatcher() } = opts;
if (agent) {
throw new InvalidArgumentError("unsupported opts.agent. Did you mean opts.client?");
}
return fn.call(dispatcher, {
...opts,
origin: url.origin,
path: url.search ? `${url.pathname}${url.search}` : url.pathname,
method: opts.method || (opts.body ? "PUT" : "GET")
}, handler);
};
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
makeDispatcher
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
function addDuplexToInit(options) {
return typeof options === "undefined" || typeof options === "object" && options.duplex === void 0 ? { duplex: "half", ...options } : options;
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
addDuplexToInit
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
constructor(input, options) {
super(input, addDuplexToInit(options));
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
async function fetch(resource, options) {
const res = await import_undici.default.fetch(resource, addDuplexToInit(options));
const response = new Response(res.body, res);
Object.defineProperty(response, "url", { value: res.url });
return response;
}
|
Closes the connection, if any, and sets the readyState attribute to
CLOSED.
|
fetch
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/fetch.js
|
MIT
|
constructor(key, value, index) {
if (index === void 0 || index >= key.length) {
throw new TypeError("Unreachable");
}
const code = this.code = key.charCodeAt(index);
if (code > 127) {
throw new TypeError("key must be ascii string");
}
if (key.length !== ++index) {
this.middle = new _TstNode(key, value, index);
} else {
this.value = value;
}
}
|
@param {string} key
@param {any} value
@param {number} index
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
add(key, value) {
const length = key.length;
if (length === 0) {
throw new TypeError("Unreachable");
}
let index = 0;
let node = this;
while (true) {
const code = key.charCodeAt(index);
if (code > 127) {
throw new TypeError("key must be ascii string");
}
if (node.code === code) {
if (length === ++index) {
node.value = value;
break;
} else if (node.middle !== null) {
node = node.middle;
} else {
node.middle = new _TstNode(key, value, index);
break;
}
} else if (node.code < code) {
if (node.left !== null) {
node = node.left;
} else {
node.left = new _TstNode(key, value, index);
break;
}
} else if (node.right !== null) {
node = node.right;
} else {
node.right = new _TstNode(key, value, index);
break;
}
}
}
|
@param {string} key
@param {any} value
|
add
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
insert(key, value) {
if (this.node === null) {
this.node = new TstNode(key, value, 0);
} else {
this.node.add(key, value);
}
}
|
@param {string} key
@param {any} value
|
insert
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(callback, delay, arg) {
this._onTimeout = callback;
this._idleTimeout = delay;
this._timerArg = arg;
this.refresh();
}
|
@constructor
@param {Function} callback A function to be executed after the timer
expires.
@param {number} delay The time, in milliseconds that the timer should wait
before the specified function or code is executed.
@param {*} arg
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
refresh() {
if (this._state === NOT_IN_LIST) {
fastTimers.push(this);
}
if (!fastNowTimeout || fastTimers.length === 1) {
refreshTimeout();
}
this._state = PENDING;
}
|
Sets the timer's start time to the current time, and reschedules the timer
to call its callback at the previously specified duration adjusted to the
current time.
Using this on a timer that has already called its callback will reactivate
the timer.
@returns {void}
|
refresh
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
clear() {
this._state = TO_BE_CLEARED;
this._idleStart = -1;
}
|
The `clear` method cancels the timer, preventing it from executing.
@returns {void}
@private
|
clear
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
setTimeout(callback, delay, arg) {
return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg);
}
|
The setTimeout() method sets a timer which executes a function once the
timer expires.
@param {Function} callback A function to be executed after the timer
expires.
@param {number} delay The time, in milliseconds that the timer should
wait before the specified function or code is executed.
@param {*} [arg] An optional argument to be passed to the callback function
when the timer expires.
@returns {NodeJS.Timeout|FastTimer}
|
setTimeout
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
clearTimeout(timeout) {
if (timeout[kFastTimer]) {
timeout.clear();
} else {
clearTimeout(timeout);
}
}
|
The clearTimeout method cancels an instantiated Timer previously created
by calling setTimeout.
@param {NodeJS.Timeout|FastTimer} timeout
|
clearTimeout
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
setFastTimeout(callback, delay, arg) {
return new FastTimer(callback, delay, arg);
}
|
The setFastTimeout() method sets a fastTimer which executes a function once
the timer expires.
@param {Function} callback A function to be executed after the timer
expires.
@param {number} delay The time, in milliseconds that the timer should
wait before the specified function or code is executed.
@param {*} [arg] An optional argument to be passed to the callback function
when the timer expires.
@returns {FastTimer}
|
setFastTimeout
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
now() {
return fastNow;
}
|
The now method returns the value of the internal fast timer clock.
@returns {number}
|
now
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
tick(delay = 0) {
fastNow += delay - RESOLUTION_MS + 1;
onTick();
onTick();
}
|
Trigger the onTick function to process the fastTimers array.
Exported for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
@param {number} [delay=0] The delay in milliseconds to add to the now value.
|
tick
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
reset() {
fastNow = 0;
fastTimers.length = 0;
clearTimeout(fastNowTimeout);
fastNowTimeout = null;
}
|
Reset FastTimers.
Exported for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
reset
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(maxCachedSessions) {
this._maxCachedSessions = maxCachedSessions;
this._sessionCache = /* @__PURE__ */ new Map();
this._sessionRegistry = new global.FinalizationRegistry((key) => {
if (this._sessionCache.size < this._maxCachedSessions) {
return;
}
const ref = this._sessionCache.get(key);
if (ref !== void 0 && ref.deref() === void 0) {
this._sessionCache.delete(key);
}
});
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get(sessionKey) {
const ref = this._sessionCache.get(sessionKey);
return ref ? ref.deref() : null;
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
get
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
set(sessionKey, session) {
if (this._maxCachedSessions === 0) {
return;
}
this._sessionCache.set(sessionKey, new WeakRef(session));
this._sessionRegistry.register(session, sessionKey);
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
set
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(maxCachedSessions) {
this._maxCachedSessions = maxCachedSessions;
this._sessionCache = /* @__PURE__ */ new Map();
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get(sessionKey) {
return this._sessionCache.get(sessionKey);
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
get
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
set(sessionKey, session) {
if (this._maxCachedSessions === 0) {
return;
}
if (this._sessionCache.size >= this._maxCachedSessions) {
const { value: oldestKey } = this._sessionCache.keys().next();
this._sessionCache.delete(oldestKey);
}
this._sessionCache.set(sessionKey, session);
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
set
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function buildConnector({ allowH2, maxCachedSessions, socketPath, timeout, session: customSession, ...opts }) {
if (maxCachedSessions != null && (!Number.isInteger(maxCachedSessions) || maxCachedSessions < 0)) {
throw new InvalidArgumentError("maxCachedSessions must be a positive integer or zero");
}
const options = { path: socketPath, ...opts };
const sessionCache = new SessionCache(maxCachedSessions == null ? 100 : maxCachedSessions);
timeout = timeout == null ? 1e4 : timeout;
allowH2 = allowH2 != null ? allowH2 : false;
return /* @__PURE__ */ __name(function connect({ hostname, host, protocol, port, servername, localAddress, httpSocket }, callback) {
let socket;
if (protocol === "https:") {
if (!tls) {
tls = require("tls");
}
servername = servername || options.servername || util.getServerName(host) || null;
const sessionKey = servername || hostname;
assert(sessionKey);
const session = customSession || sessionCache.get(sessionKey) || null;
port = port || 443;
socket = tls.connect({
highWaterMark: 16384,
// TLS in node can't have bigger HWM anyway...
...options,
servername,
session,
localAddress,
// TODO(HTTP/2): Add support for h2c
ALPNProtocols: allowH2 ? ["http/1.1", "h2"] : ["http/1.1"],
socket: httpSocket,
// upgrade socket connection
port,
host: hostname
});
socket.on("session", function(session2) {
sessionCache.set(sessionKey, session2);
});
} else {
assert(!httpSocket, "httpSocket can only be sent on TLS update");
port = port || 80;
socket = net.connect({
highWaterMark: 64 * 1024,
// Same as nodejs fs streams.
...options,
localAddress,
port,
host: hostname
});
}
if (options.keepAlive == null || options.keepAlive) {
const keepAliveInitialDelay = options.keepAliveInitialDelay === void 0 ? 6e4 : options.keepAliveInitialDelay;
socket.setKeepAlive(true, keepAliveInitialDelay);
}
const clearConnectTimeout = setupConnectTimeout(new WeakRef(socket), { timeout, hostname, port });
socket.setNoDelay(true).once(protocol === "https:" ? "secureConnect" : "connect", function() {
queueMicrotask(clearConnectTimeout);
if (callback) {
const cb = callback;
callback = null;
cb(null, this);
}
}).on("error", function(err) {
queueMicrotask(clearConnectTimeout);
if (callback) {
const cb = callback;
callback = null;
cb(err);
}
});
return socket;
}, "connect");
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
buildConnector
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function onConnectTimeout(socket, opts) {
if (socket == null) {
return;
}
let message = "Connect Timeout Error";
if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) {
message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`;
} else {
message += ` (attempted address: ${opts.hostname}:${opts.port},`;
}
message += ` timeout: ${opts.timeout}ms)`;
util.destroy(socket, new ConnectTimeoutError(message));
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
onConnectTimeout
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function enumToMap(obj) {
const res = {};
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (typeof value === "number") {
res[key] = value;
}
});
return res;
}
|
Exporting for testing purposes only.
Marking as deprecated to discourage any use outside of testing.
@deprecated
|
enumToMap
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(target, kind) {
/** @type {any} */
__privateAdd(this, _target, void 0);
/** @type {'key' | 'value' | 'key+value'} */
__privateAdd(this, _kind, void 0);
/** @type {number} */
__privateAdd(this, _index, void 0);
__privateSet(this, _target, target);
__privateSet(this, _kind, kind);
__privateSet(this, _index, 0);
}
|
@see https://webidl.spec.whatwg.org/#dfn-default-iterator-object
@param {unknown} target
@param {'key' | 'value' | 'key+value'} kind
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(url, {
interceptors,
maxHeaderSize,
headersTimeout,
socketTimeout,
requestTimeout,
connectTimeout,
bodyTimeout,
idleTimeout,
keepAlive,
keepAliveTimeout,
maxKeepAliveTimeout,
keepAliveMaxTimeout,
keepAliveTimeoutThreshold,
socketPath,
pipelining,
tls,
strictContentLength,
maxCachedSessions,
maxRedirections,
connect: connect2,
maxRequestsPerClient,
localAddress,
maxResponseSize,
autoSelectFamily,
autoSelectFamilyAttemptTimeout,
// h2
maxConcurrentStreams,
allowH2
} = {}) {
super();
if (keepAlive !== void 0) {
throw new InvalidArgumentError("unsupported keepAlive, use pipelining=0 instead");
}
if (socketTimeout !== void 0) {
throw new InvalidArgumentError("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");
}
if (requestTimeout !== void 0) {
throw new InvalidArgumentError("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");
}
if (idleTimeout !== void 0) {
throw new InvalidArgumentError("unsupported idleTimeout, use keepAliveTimeout instead");
}
if (maxKeepAliveTimeout !== void 0) {
throw new InvalidArgumentError("unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead");
}
if (maxHeaderSize != null && !Number.isFinite(maxHeaderSize)) {
throw new InvalidArgumentError("invalid maxHeaderSize");
}
if (socketPath != null && typeof socketPath !== "string") {
throw new InvalidArgumentError("invalid socketPath");
}
if (connectTimeout != null && (!Number.isFinite(connectTimeout) || connectTimeout < 0)) {
throw new InvalidArgumentError("invalid connectTimeout");
}
if (keepAliveTimeout != null && (!Number.isFinite(keepAliveTimeout) || keepAliveTimeout <= 0)) {
throw new InvalidArgumentError("invalid keepAliveTimeout");
}
if (keepAliveMaxTimeout != null && (!Number.isFinite(keepAliveMaxTimeout) || keepAliveMaxTimeout <= 0)) {
throw new InvalidArgumentError("invalid keepAliveMaxTimeout");
}
if (keepAliveTimeoutThreshold != null && !Number.isFinite(keepAliveTimeoutThreshold)) {
throw new InvalidArgumentError("invalid keepAliveTimeoutThreshold");
}
if (headersTimeout != null && (!Number.isInteger(headersTimeout) || headersTimeout < 0)) {
throw new InvalidArgumentError("headersTimeout must be a positive integer or zero");
}
if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) {
throw new InvalidArgumentError("bodyTimeout must be a positive integer or zero");
}
if (connect2 != null && typeof connect2 !== "function" && typeof connect2 !== "object") {
throw new InvalidArgumentError("connect must be a function or an object");
}
if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) {
throw new InvalidArgumentError("maxRedirections must be a positive number");
}
if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
}
if (localAddress != null && (typeof localAddress !== "string" || net.isIP(localAddress) === 0)) {
throw new InvalidArgumentError("localAddress must be valid string IP address");
}
if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) {
throw new InvalidArgumentError("maxResponseSize must be a positive number");
}
if (autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1)) {
throw new InvalidArgumentError("autoSelectFamilyAttemptTimeout must be a positive number");
}
if (allowH2 != null && typeof allowH2 !== "boolean") {
throw new InvalidArgumentError("allowH2 must be a valid boolean value");
}
if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== "number" || maxConcurrentStreams < 1)) {
throw new InvalidArgumentError("maxConcurrentStreams must be a positive integer, greater than 0");
}
if (typeof connect2 !== "function") {
connect2 = buildConnector({
...tls,
maxCachedSessions,
allowH2,
socketPath,
timeout: connectTimeout,
...autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
...connect2
});
}
if (interceptors?.Client && Array.isArray(interceptors.Client)) {
this[kInterceptors] = interceptors.Client;
if (!deprecatedInterceptorWarned) {
deprecatedInterceptorWarned = true;
define_process_default.emitWarning("Client.Options#interceptor is deprecated. Use Dispatcher#compose instead.", {
code: "UNDICI-CLIENT-INTERCEPTOR-DEPRECATED"
});
}
} else {
this[kInterceptors] = [createRedirectInterceptor({ maxRedirections })];
}
this[kUrl] = util.parseOrigin(url);
this[kConnector] = connect2;
this[kPipelining] = pipelining != null ? pipelining : 1;
this[kMaxHeadersSize] = maxHeaderSize || http.maxHeaderSize;
this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout;
this[kKeepAliveMaxTimeout] = keepAliveMaxTimeout == null ? 6e5 : keepAliveMaxTimeout;
this[kKeepAliveTimeoutThreshold] = keepAliveTimeoutThreshold == null ? 2e3 : keepAliveTimeoutThreshold;
this[kKeepAliveTimeoutValue] = this[kKeepAliveDefaultTimeout];
this[kServerName] = null;
this[kLocalAddress] = localAddress != null ? localAddress : null;
this[kResuming] = 0;
this[kNeedDrain] = 0;
this[kHostHeader] = `host: ${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ""}\r
`;
this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 3e5;
this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 3e5;
this[kStrictContentLength] = strictContentLength == null ? true : strictContentLength;
this[kMaxRedirections] = maxRedirections;
this[kMaxRequests] = maxRequestsPerClient;
this[kClosedResolve] = null;
this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1;
this[kMaxConcurrentStreams] = maxConcurrentStreams != null ? maxConcurrentStreams : 100;
this[kHTTPContext] = null;
this[kQueue] = [];
this[kRunningIdx] = 0;
this[kPendingIdx] = 0;
this[kResume] = (sync) => resume(this, sync);
this[kOnError] = (err) => onError(this, err);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get pipelining() {
return this[kPipelining];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
pipelining
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
set pipelining(value) {
this[kPipelining] = value;
this[kResume](true);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
pipelining
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function onError(client, err) {
if (client[kRunning] === 0 && err.code !== "UND_ERR_INFO" && err.code !== "UND_ERR_SOCKET") {
assert(client[kPendingIdx] === client[kRunningIdx]);
const requests = client[kQueue].splice(client[kRunningIdx]);
for (let i = 0; i < requests.length; i++) {
const request = requests[i];
util.errorRequest(client, request, err);
}
assert(client[kSize] === 0);
}
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
onError
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
async function connect(client) {
assert(!client[kConnecting]);
assert(!client[kHTTPContext]);
let { host, hostname, protocol, port } = client[kUrl];
if (hostname[0] === "[") {
const idx = hostname.indexOf("]");
assert(idx !== -1);
const ip = hostname.substring(1, idx);
assert(net.isIP(ip));
hostname = ip;
}
client[kConnecting] = true;
if (channels.beforeConnect.hasSubscribers) {
channels.beforeConnect.publish({
connectParams: {
host,
hostname,
protocol,
port,
version: client[kHTTPContext]?.version,
servername: client[kServerName],
localAddress: client[kLocalAddress]
},
connector: client[kConnector]
});
}
try {
const socket = await new Promise((resolve, reject) => {
client[kConnector]({
host,
hostname,
protocol,
port,
servername: client[kServerName],
localAddress: client[kLocalAddress]
}, (err, socket2) => {
if (err) {
reject(err);
} else {
resolve(socket2);
}
});
});
if (client.destroyed) {
util.destroy(socket.on("error", noop), new ClientDestroyedError());
return;
}
assert(socket);
try {
client[kHTTPContext] = socket.alpnProtocol === "h2" ? await connectH2(client, socket) : await connectH1(client, socket);
} catch (err) {
socket.destroy().on("error", noop);
throw err;
}
client[kConnecting] = false;
socket[kCounter] = 0;
socket[kMaxRequests] = client[kMaxRequests];
socket[kClient] = client;
socket[kError] = null;
if (channels.connected.hasSubscribers) {
channels.connected.publish({
connectParams: {
host,
hostname,
protocol,
port,
version: client[kHTTPContext]?.version,
servername: client[kServerName],
localAddress: client[kLocalAddress]
},
connector: client[kConnector],
socket
});
}
client.emit("connect", client[kUrl], [client]);
} catch (err) {
if (client.destroyed) {
return;
}
client[kConnecting] = false;
if (channels.connectError.hasSubscribers) {
channels.connectError.publish({
connectParams: {
host,
hostname,
protocol,
port,
version: client[kHTTPContext]?.version,
servername: client[kServerName],
localAddress: client[kLocalAddress]
},
connector: client[kConnector],
error: err
});
}
if (err.code === "ERR_TLS_CERT_ALTNAME_INVALID") {
assert(client[kRunning] === 0);
while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) {
const request = client[kQueue][client[kPendingIdx]++];
util.errorRequest(client, request, err);
}
} else {
onError(client, err);
}
client.emit("connectionError", client[kUrl], [client], err);
}
client[kResume]();
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
connect
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function emitDrain(client) {
client[kNeedDrain] = 0;
client.emit("drain", client[kUrl], [client]);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
emitDrain
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function resume(client, sync) {
if (client[kResuming] === 2) {
return;
}
client[kResuming] = 2;
_resume(client, sync);
client[kResuming] = 0;
if (client[kRunningIdx] > 256) {
client[kQueue].splice(0, client[kRunningIdx]);
client[kPendingIdx] -= client[kRunningIdx];
client[kRunningIdx] = 0;
}
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
resume
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function _resume(client, sync) {
while (true) {
if (client.destroyed) {
assert(client[kPending] === 0);
return;
}
if (client[kClosedResolve] && !client[kSize]) {
client[kClosedResolve]();
client[kClosedResolve] = null;
return;
}
if (client[kHTTPContext]) {
client[kHTTPContext].resume();
}
if (client[kBusy]) {
client[kNeedDrain] = 2;
} else if (client[kNeedDrain] === 2) {
if (sync) {
client[kNeedDrain] = 1;
queueMicrotask(() => emitDrain(client));
} else {
emitDrain(client);
}
continue;
}
if (client[kPending] === 0) {
return;
}
if (client[kRunning] >= (getPipelining(client) || 1)) {
return;
}
const request = client[kQueue][client[kPendingIdx]];
if (client[kUrl].protocol === "https:" && client[kServerName] !== request.servername) {
if (client[kRunning] > 0) {
return;
}
client[kServerName] = request.servername;
client[kHTTPContext]?.destroy(new InformationalError("servername changed"), () => {
client[kHTTPContext] = null;
resume(client);
});
}
if (client[kConnecting]) {
return;
}
if (!client[kHTTPContext]) {
connect(client);
return;
}
if (client[kHTTPContext].destroyed) {
return;
}
if (client[kHTTPContext].busy(request)) {
return;
}
if (!request.aborted && client[kHTTPContext].write(request)) {
client[kPendingIdx]++;
} else {
client[kQueue].splice(client[kPendingIdx], 1);
}
}
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
_resume
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor() {
this.bottom = 0;
this.top = 0;
this.list = new Array(kSize);
this.next = null;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
isEmpty() {
return this.top === this.bottom;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
isEmpty
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
isFull() {
return (this.top + 1 & kMask) === this.bottom;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
isFull
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
push(data) {
this.list[this.top] = data;
this.top = this.top + 1 & kMask;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
push
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
shift() {
const nextItem = this.list[this.bottom];
if (nextItem === void 0)
return null;
this.list[this.bottom] = void 0;
this.bottom = this.bottom + 1 & kMask;
return nextItem;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
shift
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor() {
this.head = this.tail = new FixedCircularBuffer();
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
isEmpty() {
return this.head.isEmpty();
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
isEmpty
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
push(data) {
if (this.head.isFull()) {
this.head = this.head.next = new FixedCircularBuffer();
}
this.head.push(data);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
push
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
shift() {
const tail = this.tail;
const next = tail.shift();
if (tail.isEmpty() && tail.next !== null) {
this.tail = tail.next;
}
return next;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
shift
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(pool) {
this[kPool] = pool;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get connected() {
return this[kPool][kConnected];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
connected
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get free() {
return this[kPool][kFree];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
free
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get pending() {
return this[kPool][kPending];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
pending
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get queued() {
return this[kPool][kQueued];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
queued
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get running() {
return this[kPool][kRunning];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
running
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get size() {
return this[kPool][kSize];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
size
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor() {
super();
this[kQueue] = new FixedQueue();
this[kClients] = [];
this[kQueued] = 0;
const pool = this;
this[kOnDrain] = /* @__PURE__ */ __name(function onDrain(origin, targets) {
const queue = pool[kQueue];
let needDrain = false;
while (!needDrain) {
const item = queue.shift();
if (!item) {
break;
}
pool[kQueued]--;
needDrain = !this.dispatch(item.opts, item.handler);
}
this[kNeedDrain] = needDrain;
if (!this[kNeedDrain] && pool[kNeedDrain]) {
pool[kNeedDrain] = false;
pool.emit("drain", origin, [pool, ...targets]);
}
if (pool[kClosedResolve] && queue.isEmpty()) {
Promise.all(pool[kClients].map((c) => c.close())).then(pool[kClosedResolve]);
}
}, "onDrain");
this[kOnConnect] = (origin, targets) => {
pool.emit("connect", origin, [pool, ...targets]);
};
this[kOnDisconnect] = (origin, targets, err) => {
pool.emit("disconnect", origin, [pool, ...targets], err);
};
this[kOnConnectionError] = (origin, targets, err) => {
pool.emit("connectionError", origin, [pool, ...targets], err);
};
this[kStats] = new PoolStats(this);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get stats() {
return this[kStats];
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
stats
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function defaultFactory(origin, opts) {
return new Client(origin, opts);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
defaultFactory
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(origin, {
connections,
factory = defaultFactory,
connect,
connectTimeout,
tls,
maxCachedSessions,
socketPath,
autoSelectFamily,
autoSelectFamilyAttemptTimeout,
allowH2,
...options
} = {}) {
super();
if (connections != null && (!Number.isFinite(connections) || connections < 0)) {
throw new InvalidArgumentError("invalid connections");
}
if (typeof factory !== "function") {
throw new InvalidArgumentError("factory must be a function.");
}
if (connect != null && typeof connect !== "function" && typeof connect !== "object") {
throw new InvalidArgumentError("connect must be a function or an object");
}
if (typeof connect !== "function") {
connect = buildConnector({
...tls,
maxCachedSessions,
allowH2,
socketPath,
timeout: connectTimeout,
...autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : void 0,
...connect
});
}
this[kInterceptors] = options.interceptors?.Pool && Array.isArray(options.interceptors.Pool) ? options.interceptors.Pool : [];
this[kConnections] = connections || null;
this[kUrl] = util.parseOrigin(origin);
this[kOptions] = { ...util.deepClone(options), connect, allowH2 };
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
this[kFactory] = factory;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function getGreatestCommonDivisor(a, b) {
if (a === 0)
return b;
while (b !== 0) {
const t = b;
b = a % b;
a = t;
}
return a;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
getGreatestCommonDivisor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function defaultFactory(origin, opts) {
return new Pool(origin, opts);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
defaultFactory
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(upstreams = [], { factory = defaultFactory, ...opts } = {}) {
super();
this[kOptions] = opts;
this[kIndex] = -1;
this[kCurrentWeight] = 0;
this[kMaxWeightPerServer] = this[kOptions].maxWeightPerServer || 100;
this[kErrorPenalty] = this[kOptions].errorPenalty || 15;
if (!Array.isArray(upstreams)) {
upstreams = [upstreams];
}
if (typeof factory !== "function") {
throw new InvalidArgumentError("factory must be a function.");
}
this[kInterceptors] = opts.interceptors?.BalancedPool && Array.isArray(opts.interceptors.BalancedPool) ? opts.interceptors.BalancedPool : [];
this[kFactory] = factory;
for (const upstream of upstreams) {
this.addUpstream(upstream);
}
this._updateBalancedPoolStats();
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
addUpstream(upstream) {
const upstreamOrigin = parseOrigin(upstream).origin;
if (this[kClients].find((pool2) => pool2[kUrl].origin === upstreamOrigin && pool2.closed !== true && pool2.destroyed !== true)) {
return this;
}
const pool = this[kFactory](upstreamOrigin, Object.assign({}, this[kOptions]));
this[kAddClient](pool);
pool.on("connect", () => {
pool[kWeight] = Math.min(this[kMaxWeightPerServer], pool[kWeight] + this[kErrorPenalty]);
});
pool.on("connectionError", () => {
pool[kWeight] = Math.max(1, pool[kWeight] - this[kErrorPenalty]);
this._updateBalancedPoolStats();
});
pool.on("disconnect", (...args) => {
const err = args[2];
if (err && err.code === "UND_ERR_SOCKET") {
pool[kWeight] = Math.max(1, pool[kWeight] - this[kErrorPenalty]);
this._updateBalancedPoolStats();
}
});
for (const client of this[kClients]) {
client[kWeight] = this[kMaxWeightPerServer];
}
this._updateBalancedPoolStats();
return this;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
addUpstream
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
_updateBalancedPoolStats() {
let result = 0;
for (let i = 0; i < this[kClients].length; i++) {
result = getGreatestCommonDivisor(this[kClients][i][kWeight], result);
}
this[kGreatestCommonDivisor] = result;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
_updateBalancedPoolStats
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
removeUpstream(upstream) {
const upstreamOrigin = parseOrigin(upstream).origin;
const pool = this[kClients].find((pool2) => pool2[kUrl].origin === upstreamOrigin && pool2.closed !== true && pool2.destroyed !== true);
if (pool) {
this[kRemoveClient](pool);
}
return this;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
removeUpstream
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
get upstreams() {
return this[kClients].filter((dispatcher) => dispatcher.closed !== true && dispatcher.destroyed !== true).map((p) => p[kUrl].origin);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
upstreams
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function defaultFactory(origin, opts) {
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
defaultFactory
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor({ factory = defaultFactory, maxRedirections = 0, connect, ...options } = {}) {
super();
if (typeof factory !== "function") {
throw new InvalidArgumentError("factory must be a function.");
}
if (connect != null && typeof connect !== "function" && typeof connect !== "object") {
throw new InvalidArgumentError("connect must be a function or an object");
}
if (!Number.isInteger(maxRedirections) || maxRedirections < 0) {
throw new InvalidArgumentError("maxRedirections must be a positive number");
}
if (connect && typeof connect !== "function") {
connect = { ...connect };
}
this[kInterceptors] = options.interceptors?.Agent && Array.isArray(options.interceptors.Agent) ? options.interceptors.Agent : [createRedirectInterceptor({ maxRedirections })];
this[kOptions] = { ...util.deepClone(options), connect };
this[kOptions].interceptors = options.interceptors ? { ...options.interceptors } : void 0;
this[kMaxRedirections] = maxRedirections;
this[kFactory] = factory;
this[kClients] = /* @__PURE__ */ new Map();
this[kOnDrain] = (origin, targets) => {
this.emit("drain", origin, [this, ...targets]);
};
this[kOnConnect] = (origin, targets) => {
this.emit("connect", origin, [this, ...targets]);
};
this[kOnDisconnect] = (origin, targets, err) => {
this.emit("disconnect", origin, [this, ...targets], err);
};
this[kOnConnectionError] = (origin, targets, err) => {
this.emit("connectionError", origin, [this, ...targets], err);
};
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function defaultProtocolPort(protocol) {
return protocol === "https:" ? 443 : 80;
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
defaultProtocolPort
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function defaultFactory(origin, opts) {
return new Pool(origin, opts);
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
defaultFactory
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(opts) {
super();
/**
* @param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
* @returns {URL}
*/
__privateAdd(this, _getUrl);
if (!opts || typeof opts === "object" && !(opts instanceof URL2) && !opts.uri) {
throw new InvalidArgumentError("Proxy uri is mandatory");
}
const { clientFactory = defaultFactory } = opts;
if (typeof clientFactory !== "function") {
throw new InvalidArgumentError("Proxy opts.clientFactory must be a function.");
}
const url = __privateMethod(this, _getUrl, getUrl_fn).call(this, opts);
const { href, origin, port, protocol, username, password, hostname: proxyHostname } = url;
this[kProxy] = { uri: href, protocol };
this[kInterceptors] = opts.interceptors?.ProxyAgent && Array.isArray(opts.interceptors.ProxyAgent) ? opts.interceptors.ProxyAgent : [];
this[kRequestTls] = opts.requestTls;
this[kProxyTls] = opts.proxyTls;
this[kProxyHeaders] = opts.headers || {};
if (opts.auth && opts.token) {
throw new InvalidArgumentError("opts.auth cannot be used in combination with opts.token");
} else if (opts.auth) {
this[kProxyHeaders]["proxy-authorization"] = `Basic ${opts.auth}`;
} else if (opts.token) {
this[kProxyHeaders]["proxy-authorization"] = opts.token;
} else if (username && password) {
this[kProxyHeaders]["proxy-authorization"] = `Basic ${Buffer.from(`${decodeURIComponent(username)}:${decodeURIComponent(password)}`).toString("base64")}`;
}
const connect = buildConnector({ ...opts.proxyTls });
this[kConnectEndpoint] = buildConnector({ ...opts.requestTls });
this[kClient] = clientFactory(url, { connect });
this[kAgent] = new Agent({
...opts,
connect: async (opts2, callback) => {
let requestedPath = opts2.host;
if (!opts2.port) {
requestedPath += `:${defaultProtocolPort(opts2.protocol)}`;
}
try {
const { socket, statusCode } = await this[kClient].connect({
origin,
port,
path: requestedPath,
signal: opts2.signal,
headers: {
...this[kProxyHeaders],
host: opts2.host
},
servername: this[kProxyTls]?.servername || proxyHostname
});
if (statusCode !== 200) {
socket.on("error", noop).destroy();
callback(new RequestAbortedError(`Proxy response (${statusCode}) !== 200 when HTTP Tunneling`));
}
if (opts2.protocol !== "https:") {
callback(null, socket);
return;
}
let servername;
if (this[kRequestTls]) {
servername = this[kRequestTls].servername;
} else {
servername = opts2.servername;
}
this[kConnectEndpoint]({ ...opts2, servername, httpSocket: socket }, callback);
} catch (err) {
if (err.code === "ERR_TLS_CERT_ALTNAME_INVALID") {
callback(new SecureProxyConnectionError(err));
} else {
callback(err);
}
}
}
});
}
|
@param {string|URL} url
@param {import('../../types/client.js').Client.Options} options
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
dispatch(opts, handler) {
const headers = buildHeaders(opts.headers);
throwIfProxyAuthIsSent(headers);
if (headers && !("host" in headers) && !("Host" in headers)) {
const { host } = new URL2(opts.origin);
headers.host = host;
}
return this[kAgent].dispatch(
{
...opts,
headers
},
handler
);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
dispatch
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function buildHeaders(headers) {
if (Array.isArray(headers)) {
const headersPair = {};
for (let i = 0; i < headers.length; i += 2) {
headersPair[headers[i]] = headers[i + 1];
}
return headersPair;
}
return headers;
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
buildHeaders
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function throwIfProxyAuthIsSent(headers) {
const existProxyAuth = headers && Object.keys(headers).find((key) => key.toLowerCase() === "proxy-authorization");
if (existProxyAuth) {
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
}
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
throwIfProxyAuthIsSent
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(opts = {}) {
super();
__privateAdd(this, _getProxyAgentForUrl);
__privateAdd(this, _shouldProxy);
__privateAdd(this, _parseNoProxy);
__privateAdd(this, _noProxyChanged);
__privateAdd(this, _noProxyEnv);
__privateAdd(this, _noProxyValue, null);
__privateAdd(this, _noProxyEntries, null);
__privateAdd(this, _opts, null);
__privateSet(this, _opts, opts);
if (!experimentalWarned) {
experimentalWarned = true;
define_process_default.emitWarning("EnvHttpProxyAgent is experimental, expect them to change at any time.", {
code: "UNDICI-EHPA"
});
}
const { httpProxy, httpsProxy, noProxy, ...agentOpts } = opts;
this[kNoProxyAgent] = new Agent(agentOpts);
const HTTP_PROXY = httpProxy ?? define_process_default.env.http_proxy ?? define_process_default.env.HTTP_PROXY;
if (HTTP_PROXY) {
this[kHttpProxyAgent] = new ProxyAgent({ ...agentOpts, uri: HTTP_PROXY });
} else {
this[kHttpProxyAgent] = this[kNoProxyAgent];
}
const HTTPS_PROXY = httpsProxy ?? define_process_default.env.https_proxy ?? define_process_default.env.HTTPS_PROXY;
if (HTTPS_PROXY) {
this[kHttpsProxyAgent] = new ProxyAgent({ ...agentOpts, uri: HTTPS_PROXY });
} else {
this[kHttpsProxyAgent] = this[kHttpProxyAgent];
}
__privateMethod(this, _parseNoProxy, parseNoProxy_fn).call(this);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function calculateRetryAfterHeader(retryAfter) {
const current = Date.now();
return new Date(retryAfter).getTime() - current;
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
calculateRetryAfterHeader
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(opts, handlers) {
const { retryOptions, ...dispatchOpts } = opts;
const {
// Retry scoped
retry: retryFn,
maxRetries,
maxTimeout,
minTimeout,
timeoutFactor,
// Response scoped
methods,
errorCodes,
retryAfter,
statusCodes
} = retryOptions ?? {};
this.dispatch = handlers.dispatch;
this.handler = handlers.handler;
this.opts = { ...dispatchOpts, body: wrapRequestBody(opts.body) };
this.abort = null;
this.aborted = false;
this.retryOpts = {
retry: retryFn ?? _RetryHandler[kRetryHandlerDefaultRetry],
retryAfter: retryAfter ?? true,
maxTimeout: maxTimeout ?? 30 * 1e3,
// 30s,
minTimeout: minTimeout ?? 500,
// .5s
timeoutFactor: timeoutFactor ?? 2,
maxRetries: maxRetries ?? 5,
// What errors we should retry
methods: methods ?? ["GET", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"],
// Indicates which errors to retry
statusCodes: statusCodes ?? [500, 502, 503, 504, 429],
// List of errors to retry
errorCodes: errorCodes ?? [
"ECONNRESET",
"ECONNREFUSED",
"ENOTFOUND",
"ENETDOWN",
"ENETUNREACH",
"EHOSTDOWN",
"EHOSTUNREACH",
"EPIPE",
"UND_ERR_SOCKET"
]
};
this.retryCount = 0;
this.retryCountCheckpoint = 0;
this.start = 0;
this.end = null;
this.etag = null;
this.resume = null;
this.handler.onConnect((reason) => {
this.aborted = true;
if (this.abort) {
this.abort(reason);
} else {
this.reason = reason;
}
});
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onRequestSent() {
if (this.handler.onRequestSent) {
this.handler.onRequestSent();
}
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onRequestSent
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onUpgrade(statusCode, headers, socket) {
if (this.handler.onUpgrade) {
this.handler.onUpgrade(statusCode, headers, socket);
}
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onUpgrade
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onConnect(abort) {
if (this.aborted) {
abort(this.reason);
} else {
this.abort = abort;
}
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onConnect
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onBodySent(chunk) {
if (this.handler.onBodySent)
return this.handler.onBodySent(chunk);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onBodySent
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onHeaders(statusCode, rawHeaders, resume, statusMessage) {
const headers = parseHeaders(rawHeaders);
this.retryCount += 1;
if (statusCode >= 300) {
if (this.retryOpts.statusCodes.includes(statusCode) === false) {
return this.handler.onHeaders(
statusCode,
rawHeaders,
resume,
statusMessage
);
} else {
this.abort(
new RequestRetryError("Request failed", statusCode, {
headers,
data: {
count: this.retryCount
}
})
);
return false;
}
}
if (this.resume != null) {
this.resume = null;
if (statusCode !== 206 && (this.start > 0 || statusCode !== 200)) {
this.abort(
new RequestRetryError("server does not support the range header and the payload was partially consumed", statusCode, {
headers,
data: { count: this.retryCount }
})
);
return false;
}
const contentRange = parseRangeHeader(headers["content-range"]);
if (!contentRange) {
this.abort(
new RequestRetryError("Content-Range mismatch", statusCode, {
headers,
data: { count: this.retryCount }
})
);
return false;
}
if (this.etag != null && this.etag !== headers.etag) {
this.abort(
new RequestRetryError("ETag mismatch", statusCode, {
headers,
data: { count: this.retryCount }
})
);
return false;
}
const { start, size, end = size - 1 } = contentRange;
assert(this.start === start, "content-range mismatch");
assert(this.end == null || this.end === end, "content-range mismatch");
this.resume = resume;
return true;
}
if (this.end == null) {
if (statusCode === 206) {
const range = parseRangeHeader(headers["content-range"]);
if (range == null) {
return this.handler.onHeaders(
statusCode,
rawHeaders,
resume,
statusMessage
);
}
const { start, size, end = size - 1 } = range;
assert(
start != null && Number.isFinite(start),
"content-range mismatch"
);
assert(end != null && Number.isFinite(end), "invalid content-length");
this.start = start;
this.end = end;
}
if (this.end == null) {
const contentLength = headers["content-length"];
this.end = contentLength != null ? Number(contentLength) - 1 : null;
}
assert(Number.isFinite(this.start));
assert(
this.end == null || Number.isFinite(this.end),
"invalid content-length"
);
this.resume = resume;
this.etag = headers.etag != null ? headers.etag : null;
if (this.etag != null && this.etag.startsWith("W/")) {
this.etag = null;
}
return this.handler.onHeaders(
statusCode,
rawHeaders,
resume,
statusMessage
);
}
const err = new RequestRetryError("Request failed", statusCode, {
headers,
data: { count: this.retryCount }
});
this.abort(err);
return false;
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onHeaders
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onData(chunk) {
this.start += chunk.length;
return this.handler.onData(chunk);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onData
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onComplete(rawTrailers) {
this.retryCount = 0;
return this.handler.onComplete(rawTrailers);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onComplete
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
onError(err) {
if (this.aborted || isDisturbed(this.opts.body)) {
return this.handler.onError(err);
}
if (this.retryCount - this.retryCountCheckpoint > 0) {
this.retryCount = this.retryCountCheckpoint + (this.retryCount - this.retryCountCheckpoint);
} else {
this.retryCount += 1;
}
this.retryOpts.retry(
err,
{
state: { counter: this.retryCount },
opts: { retryOptions: this.retryOpts, ...this.opts }
},
onRetry.bind(this)
);
function onRetry(err2) {
if (err2 != null || this.aborted || isDisturbed(this.opts.body)) {
return this.handler.onError(err2);
}
if (this.start !== 0) {
const headers = { range: `bytes=${this.start}-${this.end ?? ""}` };
if (this.etag != null) {
headers["if-match"] = this.etag;
}
this.opts = {
...this.opts,
headers: {
...this.opts.headers,
...headers
}
};
}
try {
this.retryCountCheckpoint = this.retryCount;
this.dispatch(this.opts, this);
} catch (err3) {
this.handler.onError(err3);
}
}
__name(onRetry, "onRetry");
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onError
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
function onRetry(err2) {
if (err2 != null || this.aborted || isDisturbed(this.opts.body)) {
return this.handler.onError(err2);
}
if (this.start !== 0) {
const headers = { range: `bytes=${this.start}-${this.end ?? ""}` };
if (this.etag != null) {
headers["if-match"] = this.etag;
}
this.opts = {
...this.opts,
headers: {
...this.opts.headers,
...headers
}
};
}
try {
this.retryCountCheckpoint = this.retryCount;
this.dispatch(this.opts, this);
} catch (err3) {
this.handler.onError(err3);
}
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
onRetry
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor(agent, options = {}) {
super(options);
__privateAdd(this, _agent, null);
__privateAdd(this, _options, null);
__privateSet(this, _agent, agent);
__privateSet(this, _options, options);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
dispatch(opts, handler) {
const retry = new RetryHandler({
...opts,
retryOptions: __privateGet(this, _options)
}, {
dispatch: __privateGet(this, _agent).dispatch.bind(__privateGet(this, _agent)),
handler
});
return __privateGet(this, _agent).dispatch(opts, retry);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
dispatch
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
close() {
return __privateGet(this, _agent).close();
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
close
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
destroy() {
return __privateGet(this, _agent).destroy();
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
destroy
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
constructor({
resume,
abort,
contentType = "",
contentLength,
highWaterMark = 64 * 1024
// Same as nodejs fs streams.
}) {
super({
autoDestroy: true,
read: resume,
highWaterMark
});
this._readableState.dataEmitted = false;
this[kAbort] = abort;
this[kConsume] = null;
this[kBody] = null;
this[kContentType] = contentType;
this[kContentLength] = contentLength;
this[kReading] = false;
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
constructor
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
destroy(err) {
if (!err && !this._readableState.endEmitted) {
err = new RequestAbortedError();
}
if (err) {
this[kAbort]();
}
return super.destroy(err);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
destroy
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
_destroy(err, callback) {
if (!this[kReading]) {
setImmediate(() => {
callback(err);
});
} else {
callback(err);
}
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
_destroy
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
on(ev, ...args) {
if (ev === "data" || ev === "readable") {
this[kReading] = true;
}
return super.on(ev, ...args);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
on
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
addListener(ev, ...args) {
return this.on(ev, ...args);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
addListener
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
off(ev, ...args) {
const ret = super.off(ev, ...args);
if (ev === "data" || ev === "readable") {
this[kReading] = this.listenerCount("data") > 0 || this.listenerCount("readable") > 0;
}
return ret;
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
off
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
removeListener(ev, ...args) {
return this.off(ev, ...args);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
removeListener
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
push(chunk) {
if (this[kConsume] && chunk !== null) {
consumePush(this[kConsume], chunk);
return this[kReading] ? super.push(chunk) : true;
}
return super.push(chunk);
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
push
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
async text() {
return consume(this, "text");
}
|
@param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts
@returns {URL}
|
text
|
javascript
|
vercel/next.js
|
packages/next/src/compiled/@edge-runtime/primitives/load.js
|
https://github.com/vercel/next.js/blob/master/packages/next/src/compiled/@edge-runtime/primitives/load.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.