vite-plugin-rpx 0.11.37 → 0.11.38

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.
Files changed (2) hide show
  1. package/dist/index.js +31 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -23267,7 +23267,7 @@ async function proxyViaPool(reqOpts) {
23267
23267
  const written = conn.socket.write(payload);
23268
23268
  if (written < payload.length)
23269
23269
  await conn.writeAll(payload.subarray(written));
23270
- return await readResponse(pool, conn, isHead);
23270
+ return await readResponse(pool, conn, isHead, reqOpts.signal);
23271
23271
  } catch (err) {
23272
23272
  const retryable = err === STALE && attempt < MAX_STALE_RETRIES && (conn.fresh || isIdempotent(method));
23273
23273
  pool.destroy(conn);
@@ -23296,7 +23296,7 @@ async function waitForHead(conn) {
23296
23296
  }
23297
23297
  return headerEnd;
23298
23298
  }
23299
- async function readResponse(pool, conn, isHead) {
23299
+ async function readResponse(pool, conn, isHead, signal) {
23300
23300
  let head;
23301
23301
  for (;; ) {
23302
23302
  const headerEnd = await waitForHead(conn);
@@ -23316,7 +23316,10 @@ async function readResponse(pool, conn, isHead) {
23316
23316
  return new Response(null, { status: head.status, headers: responseHeaders });
23317
23317
  }
23318
23318
  if (head.chunked)
23319
- return new Response(chunkedStream(pool, conn, head.closeConn), { status: head.status, headers: responseHeaders });
23319
+ return new Response(chunkedStream(pool, conn, head.closeConn, signal), {
23320
+ status: head.status,
23321
+ headers: responseHeaders
23322
+ });
23320
23323
  if (head.contentLength >= 0) {
23321
23324
  const available = conn.len - conn.pos;
23322
23325
  if (available >= head.contentLength) {
@@ -23430,11 +23433,22 @@ function untilCloseStream(conn) {
23430
23433
  }
23431
23434
  });
23432
23435
  }
23433
- function chunkedStream(pool, conn, closeConn) {
23436
+ function chunkedStream(pool, conn, closeConn, signal) {
23434
23437
  conn.streamingBody = true;
23435
23438
  let remaining = 0;
23436
23439
  let needTrailerCrlf = false;
23437
23440
  let cancelled = false;
23441
+ let downstreamController;
23442
+ const cleanupSignal = () => signal?.removeEventListener("abort", abortDownstream);
23443
+ const abortDownstream = () => {
23444
+ if (cancelled)
23445
+ return;
23446
+ cancelled = true;
23447
+ pool.destroy(conn);
23448
+ try {
23449
+ downstreamController?.close();
23450
+ } catch {}
23451
+ };
23438
23452
  async function readLine() {
23439
23453
  for (;; ) {
23440
23454
  for (let i2 = conn.pos;i2 + 1 < conn.len; i2++) {
@@ -23452,6 +23466,13 @@ function chunkedStream(pool, conn, closeConn) {
23452
23466
  }
23453
23467
  }
23454
23468
  return new ReadableStream({
23469
+ start(controller) {
23470
+ downstreamController = controller;
23471
+ if (signal?.aborted)
23472
+ abortDownstream();
23473
+ else
23474
+ signal?.addEventListener("abort", abortDownstream, { once: true });
23475
+ },
23455
23476
  async pull(controller) {
23456
23477
  try {
23457
23478
  for (;; ) {
@@ -23493,6 +23514,7 @@ function chunkedStream(pool, conn, closeConn) {
23493
23514
  break;
23494
23515
  }
23495
23516
  finishConn(pool, conn, closeConn);
23517
+ cleanupSignal();
23496
23518
  controller.close();
23497
23519
  return;
23498
23520
  }
@@ -23500,12 +23522,14 @@ function chunkedStream(pool, conn, closeConn) {
23500
23522
  }
23501
23523
  } catch (error) {
23502
23524
  pool.destroy(conn);
23525
+ cleanupSignal();
23503
23526
  if (!cancelled)
23504
23527
  controller.error(error);
23505
23528
  }
23506
23529
  },
23507
23530
  cancel() {
23508
23531
  cancelled = true;
23532
+ cleanupSignal();
23509
23533
  pool.destroy(conn);
23510
23534
  }
23511
23535
  });
@@ -23860,7 +23884,8 @@ function createProxyFetchHandler(getRoute, verbose, onNoRoute) {
23860
23884
  reqHeaders: req.headers,
23861
23885
  forwardedHost: hostname,
23862
23886
  originOverride,
23863
- body: req.body
23887
+ body: req.body,
23888
+ signal: req.signal
23864
23889
  });
23865
23890
  if (pool)
23866
23891
  markSuccess(pool, upstream);
@@ -26165,7 +26190,7 @@ init_utils();
26165
26190
  var package_default = {
26166
26191
  name: "@stacksjs/rpx",
26167
26192
  type: "module",
26168
- version: "0.11.37",
26193
+ version: "0.11.38",
26169
26194
  description: "A modern and smart reverse proxy.",
26170
26195
  author: "Chris Breuer <chris@stacksjs.org>",
26171
26196
  license: "MIT",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-rpx",
3
3
  "type": "module",
4
- "version": "0.11.37",
4
+ "version": "0.11.38",
5
5
  "description": "A modern and smart reverse proxy. Vite plugin.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  "typecheck": "bunx tsc --noEmit"
48
48
  },
49
49
  "dependencies": {
50
- "@stacksjs/rpx": "0.11.37",
50
+ "@stacksjs/rpx": "0.11.38",
51
51
  "@stacksjs/tlsx": "^0.13.13"
52
52
  },
53
53
  "simple-git-hooks": {