brass-runtime 1.18.1 → 1.19.0

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 (71) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/agent/cli/main.cjs +31 -31
  3. package/dist/agent/cli/main.js +3 -3
  4. package/dist/agent/cli/main.mjs +3 -3
  5. package/dist/agent/index.cjs +4 -4
  6. package/dist/agent/index.js +3 -3
  7. package/dist/agent/index.mjs +3 -3
  8. package/dist/{chunk-22HZQG5F.js → chunk-2R3RVNS2.js} +6 -6
  9. package/dist/{chunk-YWLLH27R.mjs → chunk-3NKXUX4T.mjs} +2 -2
  10. package/dist/{chunk-IPSMXUWA.js → chunk-4PKBNG2H.js} +38 -18
  11. package/dist/{chunk-Z3ZZMQUZ.mjs → chunk-5RVHSBJ6.mjs} +182 -34
  12. package/dist/{chunk-B5FKOLTB.mjs → chunk-5UBJT4RW.mjs} +4 -4
  13. package/dist/{chunk-5RZ7YITF.cjs → chunk-6STX4PS3.cjs} +13 -13
  14. package/dist/{chunk-XPIMJQYS.cjs → chunk-7FZUTJM3.cjs} +400 -252
  15. package/dist/{chunk-YZ5LQ32F.js → chunk-A6EG5WRL.js} +3 -3
  16. package/dist/{chunk-TTSPIU3U.js → chunk-APQBU7TM.js} +53 -32
  17. package/dist/{chunk-BC6Q6BCO.mjs → chunk-AQQQFNYD.mjs} +38 -18
  18. package/dist/{chunk-OW5VHAOE.js → chunk-B2VXVNIS.js} +1 -1
  19. package/dist/{chunk-WCBNXPN6.mjs → chunk-BLXBZ6RE.mjs} +1 -1
  20. package/dist/{chunk-7VQLEN37.js → chunk-C3CWI42G.js} +1 -1
  21. package/dist/{chunk-WI7GZF3B.cjs → chunk-DV644N7P.cjs} +85 -85
  22. package/dist/{chunk-RBHNOKH4.mjs → chunk-EKLEDIVJ.mjs} +2 -2
  23. package/dist/{chunk-S4HXADU4.js → chunk-EXBGIC66.js} +1 -1
  24. package/dist/{chunk-LSYQ3C2M.js → chunk-FC5N5QHJ.js} +2 -2
  25. package/dist/{chunk-6MLAZPBL.mjs → chunk-FNWOH2T2.js} +18 -6
  26. package/dist/{chunk-WGE2FEZE.cjs → chunk-FYWWU3Z7.cjs} +2 -2
  27. package/dist/{chunk-2OW6IFY2.cjs → chunk-GOEO763K.cjs} +21 -21
  28. package/dist/{chunk-UAKAF32U.js → chunk-GXOIUBKE.js} +2 -2
  29. package/dist/{chunk-7DU7IQHK.js → chunk-H4ZRUQZL.js} +4 -4
  30. package/dist/{chunk-JWIEMBE6.mjs → chunk-HW2CLRJ3.mjs} +6 -6
  31. package/dist/{chunk-YGR2IN4R.js → chunk-JWFOWPMB.js} +163 -155
  32. package/dist/{chunk-6V2AWT4R.mjs → chunk-KAPZHDO4.mjs} +1 -1
  33. package/dist/{chunk-EEN5OTCR.mjs → chunk-KDXNWGPB.mjs} +1 -1
  34. package/dist/{chunk-UUMKZJRJ.cjs → chunk-KPOL2YEO.cjs} +18 -6
  35. package/dist/{chunk-J6DUHITE.cjs → chunk-MA74OYCI.cjs} +6 -6
  36. package/dist/{chunk-H626ZTDZ.mjs → chunk-MUMBUXU6.mjs} +53 -32
  37. package/dist/{chunk-5LC7V2OZ.cjs → chunk-NQW3YUFN.cjs} +18 -18
  38. package/dist/{chunk-EICAJDNX.cjs → chunk-OO7BGCC3.cjs} +54 -34
  39. package/dist/{chunk-7GBJYOX7.mjs → chunk-OX6MF7SZ.mjs} +163 -155
  40. package/dist/{chunk-WVSZOPGQ.cjs → chunk-QBVS3UYN.cjs} +245 -237
  41. package/dist/{chunk-WUDHOZIH.js → chunk-RZGB3DXR.js} +182 -34
  42. package/dist/{chunk-COOW7BJX.mjs → chunk-URVS2OE2.mjs} +3 -3
  43. package/dist/{chunk-HCJ4S3YB.js → chunk-UZQ3BB6W.mjs} +18 -6
  44. package/dist/{chunk-KNTJ7FQB.cjs → chunk-YQWZ7FZX.cjs} +5 -5
  45. package/dist/{chunk-ELIECDYN.cjs → chunk-Z2YIDHRI.cjs} +5 -5
  46. package/dist/{chunk-2JHJ4YHS.cjs → chunk-ZDZNV6NA.cjs} +59 -38
  47. package/dist/core/index.cjs +8 -8
  48. package/dist/core/index.js +7 -7
  49. package/dist/core/index.mjs +7 -7
  50. package/dist/http/index.cjs +54 -54
  51. package/dist/http/index.js +7 -7
  52. package/dist/http/index.mjs +7 -7
  53. package/dist/http/testing.cjs +9 -9
  54. package/dist/http/testing.js +5 -5
  55. package/dist/http/testing.mjs +5 -5
  56. package/dist/index.cjs +86 -86
  57. package/dist/index.js +8 -8
  58. package/dist/index.mjs +8 -8
  59. package/dist/observability/index.cjs +10 -10
  60. package/dist/observability/index.js +9 -9
  61. package/dist/observability/index.mjs +9 -9
  62. package/dist/perf/cli.cjs +26 -26
  63. package/dist/perf/cli.js +11 -11
  64. package/dist/perf/cli.mjs +11 -11
  65. package/dist/perf/index.cjs +13 -13
  66. package/dist/perf/index.js +11 -11
  67. package/dist/perf/index.mjs +11 -11
  68. package/dist/schema/index.cjs +2 -2
  69. package/dist/schema/index.js +1 -1
  70. package/dist/schema/index.mjs +1 -1
  71. package/package.json +1 -1
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  Schema,
12
12
  parseConfig
13
- } from "./chunk-6MLAZPBL.mjs";
13
+ } from "./chunk-UZQ3BB6W.mjs";
14
14
 
15
15
  // src/core/runtime/ringBuffer.ts
16
16
  var PushStatus = /* @__PURE__ */ ((PushStatus3) => {
@@ -3029,32 +3029,43 @@ var NativeTopLevelRunner = class {
3029
3029
  constructor(runtime, effect, cb) {
3030
3030
  this.runtime = runtime;
3031
3031
  this.current = effect;
3032
- this.joiners.push(cb);
3033
- this.frame = {
3034
- id: 0,
3035
- runtime,
3036
- name: "native-fast-path",
3037
- fiberContext: { trace: null },
3038
- lane: runtime.lane,
3039
- status: () => this.result ? "Done" : "Running",
3040
- join: (joiner) => {
3041
- if (this.result) joiner(this.result);
3042
- else this.joiners.push(joiner);
3043
- },
3044
- interrupt: () => void 0,
3045
- addFinalizer: (finalizer) => {
3046
- this.finalizers.push(finalizer);
3047
- }
3048
- };
3032
+ this.firstJoiner = cb;
3049
3033
  }
3050
3034
  runtime;
3051
3035
  current;
3052
- stack = [];
3053
- joiners = [];
3054
- finalizers = [];
3036
+ // Lazy-allocated — most requests don't need these
3037
+ stack;
3038
+ joiners;
3039
+ finalizers;
3055
3040
  result;
3056
3041
  yielded = false;
3057
- frame;
3042
+ firstJoiner;
3043
+ // Frame is now the runner itself — avoids allocating a separate frame object
3044
+ // with 4 closures per request. We implement the Fiber-like interface inline.
3045
+ id = 0;
3046
+ name = "native-fast-path";
3047
+ fiberContext = { trace: null };
3048
+ get lane() {
3049
+ return this.runtime.lane;
3050
+ }
3051
+ // Fiber-like interface methods (used by frame consumers)
3052
+ status() {
3053
+ return this.result ? "Done" : "Running";
3054
+ }
3055
+ join(joiner) {
3056
+ if (this.result) {
3057
+ joiner(this.result);
3058
+ return;
3059
+ }
3060
+ if (!this.joiners) this.joiners = [];
3061
+ this.joiners.push(joiner);
3062
+ }
3063
+ interrupt() {
3064
+ }
3065
+ addFinalizer(finalizer) {
3066
+ if (!this.finalizers) this.finalizers = [];
3067
+ this.finalizers.push(finalizer);
3068
+ }
3058
3069
  start() {
3059
3070
  this.runLoop();
3060
3071
  }
@@ -3079,10 +3090,12 @@ var NativeTopLevelRunner = class {
3079
3090
  }
3080
3091
  break;
3081
3092
  case "FlatMap":
3093
+ if (!this.stack) this.stack = [];
3082
3094
  this.stack.push({ _tag: "SuccessCont", k: current.andThen });
3083
3095
  this.current = current.first;
3084
3096
  break;
3085
3097
  case "Fold":
3098
+ if (!this.stack) this.stack = [];
3086
3099
  this.stack.push({
3087
3100
  _tag: "FoldCont",
3088
3101
  onFailure: current.onFailure,
@@ -3097,10 +3110,12 @@ var NativeTopLevelRunner = class {
3097
3110
  this.onSuccess(this.runtime.fork(current.effect, current.scopeId));
3098
3111
  break;
3099
3112
  case "Interruptibility":
3113
+ if (!this.stack) this.stack = [];
3100
3114
  this.stack.push({ _tag: "InterruptibilityCont" });
3101
3115
  this.current = current.effect;
3102
3116
  break;
3103
3117
  case "InterruptibilityMask":
3118
+ if (!this.stack) this.stack = [];
3104
3119
  this.stack.push({ _tag: "InterruptibilityCont" });
3105
3120
  try {
3106
3121
  this.current = current.body((effect) => ({
@@ -3113,6 +3128,7 @@ var NativeTopLevelRunner = class {
3113
3128
  }
3114
3129
  break;
3115
3130
  case "InterruptibilityRestore":
3131
+ if (!this.stack) this.stack = [];
3116
3132
  this.stack.push({ _tag: "InterruptibilityCont" });
3117
3133
  this.current = current.effect;
3118
3134
  break;
@@ -3121,6 +3137,7 @@ var NativeTopLevelRunner = class {
3121
3137
  const hadValue = refs.has(current.refId);
3122
3138
  const previousValue = refs.get(current.refId);
3123
3139
  refs.set(current.refId, current.value);
3140
+ if (!this.stack) this.stack = [];
3124
3141
  this.stack.push({
3125
3142
  _tag: "FiberRefCont",
3126
3143
  refId: current.refId,
@@ -3179,7 +3196,7 @@ var NativeTopLevelRunner = class {
3179
3196
  onSuccess(value) {
3180
3197
  let currentValue = value;
3181
3198
  while (true) {
3182
- const frame = this.stack.pop();
3199
+ const frame = this.stack ? this.stack.pop() : void 0;
3183
3200
  if (!frame) {
3184
3201
  this.notify(Exit.succeed(currentValue));
3185
3202
  return;
@@ -3207,7 +3224,7 @@ var NativeTopLevelRunner = class {
3207
3224
  }
3208
3225
  onCause(cause) {
3209
3226
  let currentCause = cause;
3210
- while (this.stack.length > 0) {
3227
+ while (this.stack && this.stack.length > 0) {
3211
3228
  const frame = this.stack.pop();
3212
3229
  if (frame._tag === "InterruptibilityCont") continue;
3213
3230
  if (frame._tag === "FiberRefCont") {
@@ -3232,13 +3249,17 @@ var NativeTopLevelRunner = class {
3232
3249
  notify(exit) {
3233
3250
  if (this.result) return;
3234
3251
  this.result = exit;
3235
- this.runFinalizers(exit);
3236
- for (const joiner of this.joiners) joiner(exit);
3237
- this.joiners.length = 0;
3252
+ if (this.finalizers) this.runFinalizers(exit);
3253
+ this.firstJoiner(exit);
3254
+ if (this.joiners) {
3255
+ for (const joiner of this.joiners) joiner(exit);
3256
+ this.joiners.length = 0;
3257
+ }
3238
3258
  }
3239
3259
  runFinalizers(exit) {
3240
- while (this.finalizers.length > 0) {
3241
- const finalizer = this.finalizers.pop();
3260
+ const finalizers = this.finalizers;
3261
+ while (finalizers.length > 0) {
3262
+ const finalizer = finalizers.pop();
3242
3263
  try {
3243
3264
  const result = finalizer(exit);
3244
3265
  if (result && typeof result === "object" && "_tag" in result) {
@@ -3249,8 +3270,8 @@ var NativeTopLevelRunner = class {
3249
3270
  }
3250
3271
  }
3251
3272
  fiberRefs() {
3252
- this.frame.fiberContext.fiberRefs ??= /* @__PURE__ */ new Map();
3253
- return this.frame.fiberContext.fiberRefs;
3273
+ this.fiberContext.fiberRefs ??= /* @__PURE__ */ new Map();
3274
+ return this.fiberContext.fiberRefs;
3254
3275
  }
3255
3276
  restoreFiberRef(frame) {
3256
3277
  const refs = this.fiberRefs();
@@ -3258,7 +3279,7 @@ var NativeTopLevelRunner = class {
3258
3279
  else refs.delete(frame.refId);
3259
3280
  }
3260
3281
  withFrame(body) {
3261
- return withCurrentFiber(this.frame, body);
3282
+ return withCurrentFiber(this, body);
3262
3283
  }
3263
3284
  };
3264
3285
  function fork(effect, env) {
@@ -1,24 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkKNTJ7FQBcjs = require('./chunk-KNTJ7FQB.cjs');
4
+ var _chunkYQWZ7FZXcjs = require('./chunk-YQWZ7FZX.cjs');
5
5
 
6
6
 
7
- var _chunkWVSZOPGQcjs = require('./chunk-WVSZOPGQ.cjs');
7
+ var _chunkQBVS3UYNcjs = require('./chunk-QBVS3UYN.cjs');
8
8
 
9
9
 
10
- var _chunkWI7GZF3Bcjs = require('./chunk-WI7GZF3B.cjs');
10
+ var _chunkDV644N7Pcjs = require('./chunk-DV644N7P.cjs');
11
11
 
12
12
 
13
- var _chunkWGE2FEZEcjs = require('./chunk-WGE2FEZE.cjs');
13
+ var _chunkFYWWU3Z7cjs = require('./chunk-FYWWU3Z7.cjs');
14
14
 
15
15
 
16
16
 
17
- var _chunkXPIMJQYScjs = require('./chunk-XPIMJQYS.cjs');
17
+ var _chunk7FZUTJM3cjs = require('./chunk-7FZUTJM3.cjs');
18
18
 
19
19
 
20
20
 
21
- var _chunk2JHJ4YHScjs = require('./chunk-2JHJ4YHS.cjs');
21
+ var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
22
22
 
23
23
 
24
24
 
@@ -299,10 +299,10 @@ function makeRuntimeCase(variant, chainDepth) {
299
299
  maxCapacity: 8192,
300
300
  flushBudget: 2048
301
301
  };
302
- const scheduler = variant === "wide-scheduler" ? new (0, _chunk2JHJ4YHScjs.Scheduler)(schedulerConfig) : void 0;
303
- const recorder = variant === "recorder" ? _chunkKNTJ7FQBcjs.makeRuntimeRecorder.call(void 0, { maxEvents: 1e4 }) : void 0;
304
- const hooks = _nullishCoalesce(_optionalChain([recorder, 'optionalAccess', _8 => _8.hooks]), () => ( (variant === "active-hooks" ? new (0, _chunkWGE2FEZEcjs.EventBus)() : void 0)));
305
- const runtime = _chunk2JHJ4YHScjs.Runtime.makeWithEngine(hooks ? {} : {}, "ts", {
302
+ const scheduler = variant === "wide-scheduler" ? new (0, _chunkZDZNV6NAcjs.Scheduler)(schedulerConfig) : void 0;
303
+ const recorder = variant === "recorder" ? _chunkYQWZ7FZXcjs.makeRuntimeRecorder.call(void 0, { maxEvents: 1e4 }) : void 0;
304
+ const hooks = _nullishCoalesce(_optionalChain([recorder, 'optionalAccess', _8 => _8.hooks]), () => ( (variant === "active-hooks" ? new (0, _chunkFYWWU3Z7cjs.EventBus)() : void 0)));
305
+ const runtime = _chunkZDZNV6NAcjs.Runtime.makeWithEngine(hooks ? {} : {}, "ts", {
306
306
  hooks,
307
307
  ...scheduler ? { scheduler } : {},
308
308
  inferLane: false
@@ -349,7 +349,7 @@ function makeFlatMapChain(depth) {
349
349
  return effect;
350
350
  }
351
351
  function makeFiberRefProgram(depth) {
352
- const ref = _chunkKNTJ7FQBcjs.makeFiberRef.call(void 0, 0);
352
+ const ref = _chunkYQWZ7FZXcjs.makeFiberRef.call(void 0, 0);
353
353
  let effect = ref.set(0);
354
354
  for (let i = 0; i < depth; i++) {
355
355
  effect = _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, effect, () => ref.update((n) => n + 1));
@@ -651,7 +651,7 @@ async function profileHttpLayers(options = {}) {
651
651
  }
652
652
  async function runScenario(scenario) {
653
653
  const server = await startDummyServer(scenario.delayMs);
654
- const observability = scenario.variant === "default-json-observed" ? _chunkWI7GZF3Bcjs.makeObservability.call(void 0, {
654
+ const observability = scenario.variant === "default-json-observed" ? _chunkDV644N7Pcjs.makeObservability.call(void 0, {
655
655
  logs: false,
656
656
  traces: { maxFinishedSpans: 1e4 },
657
657
  autoStart: false
@@ -838,9 +838,9 @@ function makeDefaultJsonRunner(server, scenario, preset, disableAdaptiveLimiter
838
838
  }
839
839
  function makeProfileRuntime(concurrency, observability) {
840
840
  const capacity = Math.max(65536, concurrency * 8);
841
- return _chunk2JHJ4YHScjs.Runtime.makeWithEngine(_nullishCoalesce(_optionalChain([observability, 'optionalAccess', _30 => _30.env]), () => ( {})), "ts", {
841
+ return _chunkZDZNV6NAcjs.Runtime.makeWithEngine(_nullishCoalesce(_optionalChain([observability, 'optionalAccess', _30 => _30.env]), () => ( {})), "ts", {
842
842
  hooks: _optionalChain([observability, 'optionalAccess', _31 => _31.hooks]),
843
- scheduler: new (0, _chunk2JHJ4YHScjs.Scheduler)({
843
+ scheduler: new (0, _chunkZDZNV6NAcjs.Scheduler)({
844
844
  laneMode: "single",
845
845
  initialCapacity: capacity,
846
846
  maxCapacity: capacity,
@@ -862,24 +862,24 @@ function baseHttpConfig(baseUrl, scenario) {
862
862
  };
863
863
  }
864
864
  function makeWireClient(baseUrl, scenario) {
865
- return _chunkXPIMJQYScjs.makeHttp.call(void 0, baseHttpConfig(baseUrl, scenario));
865
+ return _chunk7FZUTJM3cjs.makeHttp.call(void 0, baseHttpConfig(baseUrl, scenario));
866
866
  }
867
867
  function makeMinimalClient(baseUrl, scenario) {
868
- return _chunkXPIMJQYScjs.makeDefaultHttpClient.call(void 0, {
868
+ return _chunk7FZUTJM3cjs.makeDefaultHttpClient.call(void 0, {
869
869
  preset: "minimal",
870
870
  compression: false,
871
871
  ...baseHttpConfig(baseUrl, scenario)
872
872
  });
873
873
  }
874
874
  function makeDefaultClient(baseUrl, scenario, preset, disableAdaptiveLimiter, observability) {
875
- return _chunkXPIMJQYScjs.makeDefaultHttpClient.call(void 0, {
875
+ return _chunk7FZUTJM3cjs.makeDefaultHttpClient.call(void 0, {
876
876
  preset,
877
877
  compression: false,
878
878
  ...baseHttpConfig(baseUrl, scenario),
879
879
  ...disableAdaptiveLimiter ? { adaptiveLimiter: false } : {},
880
880
  ...observability ? {
881
881
  middleware: [
882
- _chunkWVSZOPGQcjs.withHttpObservability.call(void 0, {
882
+ _chunkQBVS3UYNcjs.withHttpObservability.call(void 0, {
883
883
  metrics: observability.metrics,
884
884
  logs: false,
885
885
  spans: {},
@@ -6,7 +6,7 @@ var _chunkSA6HUJVIcjs = require('./chunk-SA6HUJVI.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunk2JHJ4YHScjs = require('./chunk-2JHJ4YHS.cjs');
9
+ var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
10
10
 
11
11
 
12
12
 
@@ -99,8 +99,8 @@ function makeMergePull(onLeft, onRight, flip, mergePullId) {
99
99
  const onLeftHandler = streamToRaceWithHandler("L", onLeft, onRight, flip, id);
100
100
  const onRightHandler = streamToRaceWithHandler("R", onLeft, onRight, flip, id);
101
101
  return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (_env, cb) => {
102
- const runtime = _chunk2JHJ4YHScjs.unsafeGetCurrentRuntime.call(void 0, );
103
- const scope = new (0, _chunk2JHJ4YHScjs.Scope)(runtime);
102
+ const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
103
+ const scope = new (0, _chunkZDZNV6NAcjs.Scope)(runtime);
104
104
  const handler = _chunkSA6HUJVIcjs.raceWith.call(void 0,
105
105
  uncons(onLeft),
106
106
  uncons(onRight),
@@ -160,9 +160,9 @@ function uncons(self) {
160
160
  return makeMergePull(self.left, self.right, self.flip, 0);
161
161
  case "Scoped":
162
162
  return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
163
- const runtime = _chunk2JHJ4YHScjs.unsafeGetCurrentRuntime.call(void 0, );
164
- const scope = new (0, _chunk2JHJ4YHScjs.Scope)(runtime);
165
- const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
163
+ const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
164
+ const scope = new (0, _chunkZDZNV6NAcjs.Scope)(runtime);
165
+ const fiber = _chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, );
166
166
  _optionalChain([fiber, 'optionalAccess', _2 => _2.addFinalizer, 'call', _3 => _3((exit) => {
167
167
  try {
168
168
  scope.close(exit);
@@ -183,7 +183,7 @@ function uncons(self) {
183
183
  const wrap = (s) => fromPull(
184
184
  _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env2, cb2) => {
185
185
  const pull = uncons(s);
186
- _chunk2JHJ4YHScjs.unsafeRunFoldWithEnv.call(void 0,
186
+ _chunkZDZNV6NAcjs.unsafeRunFoldWithEnv.call(void 0,
187
187
  pull,
188
188
  env2,
189
189
  (cause) => {
@@ -206,14 +206,14 @@ function uncons(self) {
206
206
  }
207
207
  scope.addFinalizer((exit) => self.release(exit));
208
208
  const inner = ex.value;
209
- _chunk2JHJ4YHScjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
209
+ _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
210
210
  });
211
211
  });
212
212
  case "Managed":
213
213
  return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
214
- const runtime = _chunk2JHJ4YHScjs.unsafeGetCurrentRuntime.call(void 0, );
215
- const scope = new (0, _chunk2JHJ4YHScjs.Scope)(runtime);
216
- _optionalChain([_chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, ), 'optionalAccess', _4 => _4.addFinalizer, 'call', _5 => _5((exit) => {
214
+ const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
215
+ const scope = new (0, _chunkZDZNV6NAcjs.Scope)(runtime);
216
+ _optionalChain([_chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, ), 'optionalAccess', _4 => _4.addFinalizer, 'call', _5 => _5((exit) => {
217
217
  try {
218
218
  scope.close(exit);
219
219
  } catch (e4) {
@@ -241,7 +241,7 @@ function uncons(self) {
241
241
  scope.addFinalizer((exit) => release(exit));
242
242
  const wrap = (s) => fromPull(
243
243
  _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env2, cb2) => {
244
- _chunk2JHJ4YHScjs.unsafeRunFoldWithEnv.call(void 0,
244
+ _chunkZDZNV6NAcjs.unsafeRunFoldWithEnv.call(void 0,
245
245
  uncons(s),
246
246
  env2,
247
247
  (cause) => {
@@ -255,7 +255,7 @@ function uncons(self) {
255
255
  );
256
256
  })
257
257
  );
258
- _chunk2JHJ4YHScjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
258
+ _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, ).fork(uncons(wrap(inner))).join(cb);
259
259
  });
260
260
  });
261
261
  }
@@ -412,31 +412,49 @@ function drainStreamSyncFull(stream) {
412
412
  }
413
413
  }
414
414
  }
415
+ var ABORTED_ERROR = (() => {
416
+ if (typeof DOMException === "function") {
417
+ try {
418
+ return new DOMException("aborted", "AbortError");
419
+ } catch (e5) {
420
+ }
421
+ }
422
+ const e = new Error("aborted");
423
+ e.name = "AbortError";
424
+ return e;
425
+ })();
415
426
  function readerStream(reader, normalizeError, signal) {
427
+ const noopSignal = globalThis.__brassNoopSignal;
428
+ const needsSignalListener = signal !== void 0 && signal !== noopSignal;
416
429
  const pull = _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (_, cb) => {
417
430
  let done = false;
418
- const cleanup = () => _optionalChain([signal, 'optionalAccess', _6 => _6.removeEventListener, 'call', _7 => _7("abort", abort)]);
431
+ let abortFn;
419
432
  const finish = (exit) => {
420
433
  if (done) return;
421
434
  done = true;
422
- cleanup();
435
+ if (needsSignalListener && abortFn) signal.removeEventListener("abort", abortFn);
423
436
  cb(exit);
424
437
  };
425
- const abort = () => {
426
- try {
427
- reader.cancel();
428
- } catch (e5) {
438
+ if (needsSignalListener) {
439
+ if (signal.aborted) {
440
+ try {
441
+ reader.cancel();
442
+ } catch (e6) {
443
+ }
444
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.some.call(void 0, normalizeError(ABORTED_ERROR)) } });
445
+ return;
429
446
  }
430
- const error = typeof DOMException === "function" ? new DOMException("aborted", "AbortError") : new Error("aborted");
431
- finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.some.call(void 0, normalizeError(error)) } });
432
- };
433
- if (_optionalChain([signal, 'optionalAccess', _8 => _8.aborted])) {
434
- abort();
435
- return;
447
+ abortFn = () => {
448
+ try {
449
+ reader.cancel();
450
+ } catch (e7) {
451
+ }
452
+ finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.some.call(void 0, normalizeError(ABORTED_ERROR)) } });
453
+ };
454
+ signal.addEventListener("abort", abortFn, { once: true });
436
455
  }
437
- _optionalChain([signal, 'optionalAccess', _9 => _9.addEventListener, 'call', _10 => _10("abort", abort, { once: true })]);
438
- reader.read().then(({ done: done2, value }) => {
439
- if (done2) {
456
+ reader.read().then(({ done: readDone, value }) => {
457
+ if (readDone) {
440
458
  finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.none } });
441
459
  return;
442
460
  }
@@ -444,14 +462,16 @@ function readerStream(reader, normalizeError, signal) {
444
462
  _tag: "Success",
445
463
  value: [value, fromPull(pull)]
446
464
  });
447
- }).catch((e) => {
465
+ }, (e) => {
448
466
  finish({ _tag: "Failure", cause: { _tag: "Fail", error: _chunkMVGUEJ5Zcjs.some.call(void 0, normalizeError(e)) } });
449
467
  });
450
468
  return () => {
451
- cleanup();
469
+ if (done) return;
470
+ done = true;
471
+ if (needsSignalListener && abortFn) signal.removeEventListener("abort", abortFn);
452
472
  try {
453
473
  reader.cancel();
454
- } catch (e6) {
474
+ } catch (e8) {
455
475
  }
456
476
  };
457
477
  });
@@ -469,10 +489,10 @@ function streamFromReadableStream(body, normalizeError, options = {}) {
469
489
  // release: se corre en fin / error / interrupción
470
490
  () => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
471
491
  try {
472
- _optionalChain([reader, 'optionalAccess', _11 => _11.cancel, 'call', _12 => _12()]);
473
- } catch (e7) {
492
+ _optionalChain([reader, 'optionalAccess', _6 => _6.cancel, 'call', _7 => _7()]);
493
+ } catch (e9) {
474
494
  } finally {
475
- _optionalChain([options, 'access', _13 => _13.onRelease, 'optionalCall', _14 => _14()]);
495
+ _optionalChain([options, 'access', _8 => _8.onRelease, 'optionalCall', _9 => _9()]);
476
496
  }
477
497
  })
478
498
  );