LCOV - code coverage report
Current view: top level - src/platform/telemetry - assetLoadErrorReporting.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 0.0 % 6 0
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { parsePreloadError } from '@/utils/preloadErrorUtil'
       2              : 
       3              : import { reportError } from '@comfyorg/telemetry/reportError'
       4              : 
       5              : import { isExtensionImportError } from './customNodeLoadTelemetry'
       6              : 
       7              : /**
       8              :  * Whether a failed resource is one we ship, and can therefore act on.
       9              :  *
      10              :  * The `error` listener in `App.vue` fires for every `<script>` and
      11              :  * `<link rel=stylesheet>` on the page, including the ones GTM, Meta and the
      12              :  * other marketing tags inject at runtime. Those fail constantly and for one
      13              :  * reason: the visitor runs an ad blocker. Reporting them made
      14              :  * `Resource load failed: …` the single largest error group on
      15              :  * cloud-frontend-prod, and because Sentry groups on this function's frame
      16              :  * rather than on the URL, every blocked host landed in ONE issue with our own
      17              :  * asset failures — so the group could be neither read nor archived without
      18              :  * losing the failures that matter.
      19              :  *
      20              :  * Same-origin is the line: our JS and CSS are served from the page's origin.
      21              :  * A URL we cannot parse is reported rather than dropped, because an unparseable
      22              :  * asset URL is itself a bug worth seeing.
      23              :  *
      24              :  * Accepted loss: `t.comfy.org` (the PostHog proxy) is ours but cross-origin, so
      25              :  * its load failures stop being reported here. They are overwhelmingly the same
      26              :  * ad blockers, and a real outage of that host shows up as missing PostHog
      27              :  * volume, which is the signal that would actually be watched.
      28              :  */
      29              : function isFirstPartyResource(url: string): boolean {
      30              :   try {
      31              :     return new URL(url, window.location.href).origin === window.location.origin
      32              :   } catch {
      33              :     return true
      34              :   }
      35              : }
      36              : 
      37              : /**
      38              :  * Asset failures reach a sink only on cloud builds, and `reportError` writes
      39              :  * the console line there. Every other distribution logs locally instead, so
      40              :  * one failure never produces two console lines or two RUM events.
      41              :  *
      42              :  * Third-party resources are dropped on every distribution: they are not ours to
      43              :  * fix, and the local console line is as much noise as the Sentry event.
      44              :  */
      45              : export function reportResourceLoadError(url: string, tagName: string): void {
      46              :   if (!isFirstPartyResource(url)) return
      47              : 
      48              :   if (__DISTRIBUTION__ !== 'cloud') {
      49              :     console.error('[resource:loadError]', { url, tagName })
      50              :     return
      51              :   }
      52              : 
      53              :   reportError(new Error(`Resource load failed: ${url}`), {
      54              :     surface: 'platform',
      55              :     errorType: 'resource_load_error',
      56              :     tags: { tag_name: tagName }
      57              :   })
      58              : }
      59              : 
      60            0 : export function reportPreloadError(error: Error): void {
      61            0 :   const info = parsePreloadError(error)
      62              : 
      63              :   if (__DISTRIBUTION__ !== 'cloud') {
      64            0 :     console.error('[vite:preloadError]', {
      65              :       url: info.url,
      66              :       fileType: info.fileType,
      67              :       chunkName: info.chunkName,
      68              :       message: info.message
      69              :     })
      70              :     return
      71              :   }
      72              : 
      73              :   reportError(error, {
      74              :     surface: 'platform',
      75              :     errorType: 'vite_preload_error',
      76              :     tags: {
      77              :       file_type: info.fileType,
      78              :       chunk_name: info.chunkName ?? undefined
      79              :     },
      80              :     context: {
      81              :       url: info.url,
      82              :       fileType: info.fileType,
      83              :       chunkName: info.chunkName
      84              :     }
      85              :   })
      86              : }
      87              : 
      88              : /**
      89              :  * Reports a preload failure that was left to reject at its importer, unless
      90              :  * the extension loader caught it, since that loader reports it with the
      91              :  * extension's path as `error_loading_extension`.
      92              :  */
      93            0 : export function reportPreloadErrorUnlessExtensionImport(error: Error): void {
      94            0 :   setTimeout(() => {
      95            0 :     if (!isExtensionImportError(error)) reportPreloadError(error)
      96              :   })
      97              : }
        

Generated by: LCOV version 2.0-1