All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.cjs.anr.js.map Maven / Gradle / Ivy

There is a newer version: 8.38.0
Show newest version
{"version":3,"file":"anr.js","sources":["../../src/anr.ts"],"sourcesContent":["import type { StackFrame } from '@sentry/types';\nimport { filenameIsInApp } from './node-stack-trace';\nimport { dropUndefinedKeys } from './object';\nimport { UNKNOWN_FUNCTION } from './stacktrace';\n\ntype WatchdogReturn = {\n  /** Resets the watchdog timer */\n  poll: () => void;\n  /** Enables or disables the watchdog timer */\n  enabled: (state: boolean) => void;\n};\n\ntype CreateTimerImpl = () => { getTimeMs: () => number; reset: () => void };\n\n/**\n * A node.js watchdog timer\n * @param pollInterval The interval that we expect to get polled at\n * @param anrThreshold The threshold for when we consider ANR\n * @param callback The callback to call for ANR\n * @returns An object with `poll` and `enabled` functions {@link WatchdogReturn}\n */\nexport function watchdogTimer(\n  createTimer: CreateTimerImpl,\n  pollInterval: number,\n  anrThreshold: number,\n  callback: () => void,\n): WatchdogReturn {\n  const timer = createTimer();\n  let triggered = false;\n  let enabled = true;\n\n  setInterval(() => {\n    const diffMs = timer.getTimeMs();\n\n    if (triggered === false && diffMs > pollInterval + anrThreshold) {\n      triggered = true;\n      if (enabled) {\n        callback();\n      }\n    }\n\n    if (diffMs < pollInterval + anrThreshold) {\n      triggered = false;\n    }\n  }, 20);\n\n  return {\n    poll: () => {\n      timer.reset();\n    },\n    enabled: (state: boolean) => {\n      enabled = state;\n    },\n  };\n}\n\n// types copied from inspector.d.ts\ninterface Location {\n  scriptId: string;\n  lineNumber: number;\n  columnNumber?: number;\n}\n\ninterface CallFrame {\n  functionName: string;\n  location: Location;\n  url: string;\n}\n\n/**\n * Converts Debugger.CallFrame to Sentry StackFrame\n */\nexport function callFrameToStackFrame(\n  frame: CallFrame,\n  url: string | undefined,\n  getModuleFromFilename: (filename: string | undefined) => string | undefined,\n): StackFrame {\n  const filename = url ? url.replace(/^file:\\/\\//, '') : undefined;\n\n  // CallFrame row/col are 0 based, whereas StackFrame are 1 based\n  const colno = frame.location.columnNumber ? frame.location.columnNumber + 1 : undefined;\n  const lineno = frame.location.lineNumber ? frame.location.lineNumber + 1 : undefined;\n\n  return dropUndefinedKeys({\n    filename,\n    module: getModuleFromFilename(filename),\n    function: frame.functionName || UNKNOWN_FUNCTION,\n    colno,\n    lineno,\n    in_app: filename ? filenameIsInApp(filename) : undefined,\n  });\n}\n"],"names":["dropUndefinedKeys","UNKNOWN_FUNCTION","filenameIsInApp"],"mappings":";;;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa;AAC7B,EAAE,WAAW;AACb,EAAE,YAAY;AACd,EAAE,YAAY;AACd,EAAE,QAAQ;AACV,EAAkB;AAClB,EAAE,MAAM,KAAA,GAAQ,WAAW,EAAE,CAAA;AAC7B,EAAE,IAAI,SAAU,GAAE,KAAK,CAAA;AACvB,EAAE,IAAI,OAAQ,GAAE,IAAI,CAAA;AACpB;AACA,EAAE,WAAW,CAAC,MAAM;AACpB,IAAI,MAAM,MAAO,GAAE,KAAK,CAAC,SAAS,EAAE,CAAA;AACpC;AACA,IAAI,IAAI,SAAA,KAAc,KAAA,IAAS,MAAA,GAAS,YAAA,GAAe,YAAY,EAAE;AACrE,MAAM,SAAA,GAAY,IAAI,CAAA;AACtB,MAAM,IAAI,OAAO,EAAE;AACnB,QAAQ,QAAQ,EAAE,CAAA;AAClB,OAAM;AACN,KAAI;AACJ;AACA,IAAI,IAAI,MAAA,GAAS,YAAa,GAAE,YAAY,EAAE;AAC9C,MAAM,SAAA,GAAY,KAAK,CAAA;AACvB,KAAI;AACJ,GAAG,EAAE,EAAE,CAAC,CAAA;AACR;AACA,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,MAAM,KAAK,CAAC,KAAK,EAAE,CAAA;AACnB,KAAK;AACL,IAAI,OAAO,EAAE,CAAC,KAAK,KAAc;AACjC,MAAM,OAAA,GAAU,KAAK,CAAA;AACrB,KAAK;AACL,GAAG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