peachsim 0.1.2593 → 0.1.2594

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 (127) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +2 -2
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-DLENU3SM.mjs → acorn-M67PRRGJ.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-JPNUGMLE.mjs → chunk-3VEDDAPT.mjs} +5 -5
  28. package/dist-lib/esm-chunks/{chunk-LK3KQ4X3.mjs → chunk-4AOZYVB2.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-2UERF2EN.mjs → chunk-6MZ5FKMK.mjs} +2 -2
  30. package/dist-lib/esm-chunks/{chunk-IT4CC3HU.mjs → chunk-EDBGKIQ2.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-DLSPHUHQ.mjs → chunk-FFHDCOXF.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-TXBZEHNH.mjs → chunk-GER2Z6BI.mjs} +4 -4
  33. package/dist-lib/esm-chunks/{chunk-XFFPOSW2.mjs → chunk-HJJI36KV.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-NIYJBFXV.mjs → chunk-INOLFCG5.mjs} +3 -3
  35. package/dist-lib/esm-chunks/{chunk-BMKI4WBL.mjs → chunk-IUDVBSA4.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-UZPLSN2V.mjs → chunk-NN73CP4F.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-KWMJUJJS.mjs → chunk-PESI6OUB.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-LN7ZTBNS.mjs → chunk-QHYHKB3J.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-ZT5ZXQC2.mjs → chunk-QSPPJOT6.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-UM4DCXPA.mjs → chunk-QUMKCF67.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-6O2M4J2Y.mjs → chunk-RESE3ERA.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-GFMQ5PNX.mjs → chunk-SBHXHWKH.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-OIHSBING.mjs → chunk-SV76NV36.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-4YJJKKKF.mjs → chunk-UAEIMMNH.mjs} +5 -5
  45. package/dist-lib/esm-chunks/{chunk-2MWUVSRW.mjs → chunk-X242Y5KS.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-23D4W2EY.mjs → chunk-XM3OLATO.mjs} +12 -12
  47. package/dist-lib/esm-chunks/{chunk-P3A4MQHR.mjs → chunk-YGDCMWUX.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-E6OGMX3T.mjs → chunk-Z6E7GAQS.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-DHGC2DVE.mjs → metro-layout-parser-ZJUAU4C3.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-ROIDLGLU.mjs → swift-package-prebuilt-2FFVA7SB.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-5VU63S56.mjs → swift-sdk-app-module-A2ZJMCBX.mjs} +14 -14
  52. package/dist-lib/esm-chunks/{swift-sdk-image-SNFZVUQ3.mjs → swift-sdk-image-HJLWK2B6.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-5RQDIX53.mjs → swift-sdk-image-producer-7EM7U2LR.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +2 -2
  55. package/dist-lib/expo-swift-metadata.cjs +1 -1
  56. package/dist-lib/expo-swift-metadata.mjs +7 -7
  57. package/dist-lib/home-paths.cjs +1 -1
  58. package/dist-lib/host/bridge-host.cjs +61 -11
  59. package/dist-lib/host/fetch-proxy-handler.cjs +61 -11
  60. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  61. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  62. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  63. package/dist-lib/host/websocket-proxy.cjs +1 -1
  64. package/dist-lib/index.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +3 -3
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +4 -4
  72. package/dist-lib/native-app-identity-project.cjs +1 -1
  73. package/dist-lib/native-app-identity-project.mjs +16 -16
  74. package/dist-lib/native-app-identity.cjs +1 -1
  75. package/dist-lib/native-app-identity.mjs +6 -6
  76. package/dist-lib/native-firebase-metadata.cjs +1 -1
  77. package/dist-lib/native-firebase-metadata.mjs +3 -3
  78. package/dist-lib/pdfium-raster.cjs +1 -1
  79. package/dist-lib/pdfium-raster.mjs +2 -2
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +3 -3
  82. package/dist-lib/profiles.cjs +1 -1
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +81 -81
  85. package/dist-lib/public-origins-lib.json +69 -69
  86. package/dist-lib/react-native-host-modules.cjs +1 -1
  87. package/dist-lib/react-native-host-modules.mjs +2 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +1 -1
  91. package/dist-lib/sdk.mjs +8 -8
  92. package/dist-lib/skills.cjs +61 -11
  93. package/dist-lib/swift-compile.cjs +1 -1
  94. package/dist-lib/swift-compile.mjs +10 -10
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +3 -3
  97. package/dist-lib/swift-submit.cjs +1 -1
  98. package/dist-lib/swift-submit.mjs +6 -6
  99. package/dist-lib/swift-svg-raster.cjs +1 -1
  100. package/dist-lib/swift-svg-raster.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +1 -1
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  106. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  107. package/dist-lib/vendor/acorn.cjs +1 -1
  108. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  109. package/dist-lib/vendor/ignore.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/plist.cjs +1 -1
  112. package/dist-lib/vendor/smol-toml.cjs +1 -1
  113. package/dist-lib/vendor/stream-json.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase.cjs +1 -1
  119. package/dist-lib/vendor/terser.cjs +1 -1
  120. package/dist-lib/vendor/valibot.cjs +1 -1
  121. package/dist-lib/vendor/ws.cjs +1 -1
  122. package/dist-lib/vendor/zod.cjs +1 -1
  123. package/dist-lib/worklet-executable.cjs +1 -1
  124. package/dist-lib/worklet-executable.mjs +3 -3
  125. package/kotlin/sdk.tar.gz +0 -0
  126. package/package.json +1 -1
  127. package/src/host/fetch-proxy-handler.ts +63 -9
@@ -60,6 +60,15 @@ import type { SecureVersion } from 'node:tls'
60
60
  type FetchProxyRequest = IncomingMessage | Http2ServerRequest
61
61
  type FetchProxyResponse = ServerResponse | Http2ServerResponse
62
62
 
63
+ function isClientResponseClosed(
64
+ req: FetchProxyRequest,
65
+ res: FetchProxyResponse,
66
+ ): boolean {
67
+ if (res.destroyed || res.writableEnded || res.writableFinished) return true
68
+ if (req instanceof Http2ServerRequest) return req.stream.destroyed || req.stream.closed
69
+ return req.aborted || Boolean(req.socket?.destroyed)
70
+ }
71
+
63
72
  // every proxied request reuses one pooled, keep-alive connection per upstream
64
73
  // host instead of opening (and TLS-handshaking) a fresh socket per request.
65
74
  // node's default global agents have `keepAlive: false`, so without this every
@@ -427,6 +436,17 @@ async function proxyUpstream(
427
436
  respond: (upstream: IncomingMessage, setCookies: string[]) => void | Promise<void>
428
437
  },
429
438
  ): Promise<void> {
439
+ let clientClosed = isClientResponseClosed(req, res)
440
+ let activeUpstream: IncomingMessage | undefined
441
+ const hasClientClosed = () => clientClosed || isClientResponseClosed(req, res)
442
+ if (clientClosed) return
443
+ const markClosed = () => {
444
+ if (res.writableFinished) return
445
+ clientClosed = true
446
+ if (activeUpstream && !activeUpstream.destroyed) activeUpstream.destroy()
447
+ }
448
+ req.once('aborted', markClosed)
449
+ res.once('close', markClosed)
430
450
  const originalMethod = req.method || 'GET'
431
451
  const minimumHeader = req.headers[FETCH_PROXY_TLS_MINIMUM_HEADER]
432
452
  const minimumVersion =
@@ -438,6 +458,7 @@ async function proxyUpstream(
438
458
  redirects: number,
439
459
  setCookies: string[],
440
460
  ): Promise<void> => {
461
+ if (hasClientClosed()) return
441
462
  const transport = targetUrl.protocol === 'https:' ? https : http
442
463
  const targetHeaders = route.requestHeaders(targetUrl)
443
464
  if (targetUrl.origin !== upstreamUrl.origin) {
@@ -462,6 +483,7 @@ async function proxyUpstream(
462
483
  body: nextBody,
463
484
  })
464
485
  if (!allowed) throw new NetworkPolicyDeniedError(`${method} ${targetUrl.origin}`)
486
+ if (hasClientClosed()) return
465
487
 
466
488
  const port = projectLoopbackPort(
467
489
  targetUrl.hostname,
@@ -472,13 +494,12 @@ async function proxyUpstream(
472
494
  // response. a browser and URLSession resend the request on another
473
495
  // connection then, whatever its method; each stale socket is discarded,
474
496
  // so this ends at a fresh connection
475
- let clientAborted = false
476
- const markAborted = () => {
477
- clientAborted = true
478
- }
479
- req.once('aborted', markAborted)
480
497
  const send = () =>
481
498
  new Promise<IncomingMessage>((resolve, reject) => {
499
+ if (hasClientClosed()) {
500
+ reject(new Error('client closed before upstream request'))
501
+ return
502
+ }
482
503
  let responded = false
483
504
  const proxyReq = transport.request(
484
505
  {
@@ -515,9 +536,15 @@ async function proxyUpstream(
515
536
  // response and return that socket to the pool, error listener detached,
516
537
  // before the socket emits it. the request still fails through its own
517
538
  // 'error' (socket hang up)
518
- const abort = () => proxyReq.destroy()
539
+ const abort = () => {
540
+ if (!res.writableFinished) proxyReq.destroy()
541
+ }
519
542
  req.once('aborted', abort)
520
- proxyReq.once('close', () => req.off('aborted', abort))
543
+ res.once('close', abort)
544
+ proxyReq.once('close', () => {
545
+ req.off('aborted', abort)
546
+ res.off('close', abort)
547
+ })
521
548
  // listen for the request's whole life, never once: how many 'error'
522
549
  // events one destroy(err) emits depends on the runtime (node 25 emits
523
550
  // the abort twice when it lands while a pooled socket is being handed
@@ -529,7 +556,7 @@ async function proxyUpstream(
529
556
  if (
530
557
  proxyReq.reusedSocket &&
531
558
  !responded &&
532
- !clientAborted &&
559
+ !hasClientClosed() &&
533
560
  err.code === 'ECONNRESET'
534
561
  )
535
562
  resolve(send())
@@ -538,8 +565,13 @@ async function proxyUpstream(
538
565
  if (nextBody === undefined) proxyReq.end()
539
566
  else proxyReq.end(nextBody)
540
567
  })
541
- const proxyRes = await send().finally(() => req.off('aborted', markAborted))
568
+ const proxyRes = await send()
569
+ activeUpstream = proxyRes
542
570
  upstreamAnswered = true
571
+ if (hasClientClosed()) {
572
+ proxyRes.destroy()
573
+ return
574
+ }
543
575
 
544
576
  const status = proxyRes.statusCode ?? 502
545
577
  const location = proxyRes.headers.location
@@ -556,6 +588,10 @@ async function proxyUpstream(
556
588
  if (minimumVersion && targetUrl.protocol === 'https:')
557
589
  res.setHeader(FETCH_PROXY_TLS_ENFORCED_HEADER, minimumHeader!)
558
590
  await route.respond(proxyRes, hopCookies)
591
+ if (hasClientClosed()) {
592
+ proxyRes.destroy()
593
+ return
594
+ }
559
595
  if (isNativeCookieRedirect(hop)) res.removeHeader('location')
560
596
  res.statusCode = isNativeCookieRedirect(hop) ? 200 : status
561
597
  await pipeline(proxyRes, res)
@@ -579,6 +615,7 @@ async function proxyUpstream(
579
615
  const redirectUrl = resolveRedirectUrl(location, targetUrl)
580
616
  proxyRes.resume()
581
617
  await finished(proxyRes)
618
+ if (hasClientClosed()) return
582
619
  await proxy(
583
620
  redirectUrl,
584
621
  switchToGet ? 'GET' : method,
@@ -591,6 +628,10 @@ async function proxyUpstream(
591
628
 
592
629
  if (redirects > 0) res.setHeader(FETCH_PROXY_RESPONSE_URL_HEADER, targetUrl.href)
593
630
  await route.respond(proxyRes, hopCookies)
631
+ if (hasClientClosed()) {
632
+ proxyRes.destroy()
633
+ return
634
+ }
594
635
  res.statusCode = status
595
636
  if (
596
637
  isBundleProxyRequestUrl(req.url) &&
@@ -600,6 +641,10 @@ async function proxyUpstream(
600
641
  ) {
601
642
  const { forwardRolldownBundleResponse } =
602
643
  await import('./rolldown-bundle-forward.ts')
644
+ if (hasClientClosed()) {
645
+ proxyRes.destroy()
646
+ return
647
+ }
603
648
  await forwardRolldownBundleResponse(proxyRes, res)
604
649
  return
605
650
  }
@@ -622,6 +667,10 @@ async function proxyUpstream(
622
667
  }
623
668
  await proxy(upstreamUrl, originalMethod, body, 0, [])
624
669
  } catch (err) {
670
+ if (hasClientClosed()) {
671
+ if (activeUpstream && !activeUpstream.destroyed) activeUpstream.destroy()
672
+ return
673
+ }
625
674
  const norm = normalizeHostname(upstreamUrl.hostname)
626
675
  // an upstream that answered while this host then failed to forward it is a
627
676
  // host defect the page can only see as a dropped connection, so name it
@@ -642,6 +691,7 @@ async function proxyUpstream(
642
691
  ? ['[::1]']
643
692
  : ['[::1]', '127.0.0.1']
644
693
  for (const altHost of altHosts) {
694
+ if (hasClientClosed()) return
645
695
  try {
646
696
  const altUrl = new URL(upstreamUrl.href)
647
697
  altUrl.hostname = altHost
@@ -650,6 +700,7 @@ async function proxyUpstream(
650
700
  } catch {}
651
701
  }
652
702
  }
703
+ if (hasClientClosed()) return
653
704
  if (!res.headersSent && reportFailure) {
654
705
  const code = (err as { code?: unknown })?.code
655
706
  res.statusCode = 502
@@ -682,5 +733,8 @@ async function proxyUpstream(
682
733
  if (req instanceof Http2ServerRequest)
683
734
  req.stream.destroy(new Error('fetch proxy upstream failed', { cause: err }))
684
735
  else req.socket.destroy()
736
+ } finally {
737
+ req.off('aborted', markClosed)
738
+ res.off('close', markClosed)
685
739
  }
686
740
  }