@errpulse/node
Advanced tools
+107
-0
@@ -86,2 +86,21 @@ "use strict"; | ||
| ]; | ||
| var SENSITIVE_FIELDS = [ | ||
| "password", | ||
| "passwd", | ||
| "secret", | ||
| "token", | ||
| "apiKey", | ||
| "api_key", | ||
| "accessToken", | ||
| "access_token", | ||
| "refreshToken", | ||
| "refresh_token", | ||
| "creditCard", | ||
| "credit_card", | ||
| "ssn", | ||
| "cardNumber", | ||
| "card_number", | ||
| "cvv", | ||
| "cvc" | ||
| ]; | ||
| var REDACTED = "[Redacted]"; | ||
@@ -99,2 +118,20 @@ function sanitizeHeaders(headers) { | ||
| } | ||
| function sanitizeObject(obj) { | ||
| if (obj === null || obj === void 0) return obj; | ||
| if (typeof obj !== "object") return obj; | ||
| if (Array.isArray(obj)) { | ||
| return obj.map(sanitizeObject); | ||
| } | ||
| const sanitized = {}; | ||
| for (const [key, value] of Object.entries(obj)) { | ||
| if (SENSITIVE_FIELDS.some((f) => key.toLowerCase().includes(f.toLowerCase()))) { | ||
| sanitized[key] = REDACTED; | ||
| } else if (typeof value === "object" && value !== null) { | ||
| sanitized[key] = sanitizeObject(value); | ||
| } else { | ||
| sanitized[key] = value; | ||
| } | ||
| } | ||
| return sanitized; | ||
| } | ||
| function generateEventId() { | ||
@@ -395,2 +432,23 @@ return (0, import_crypto.randomBytes)(16).toString("hex"); | ||
| // src/integrations/express.ts | ||
| var MAX_BODY_SIZE = 16 * 1024; | ||
| function flattenHeaders(headers) { | ||
| const flat = {}; | ||
| for (const [key, value] of Object.entries(headers)) { | ||
| if (value === void 0) continue; | ||
| flat[key] = Array.isArray(value) ? value.join(", ") : String(value); | ||
| } | ||
| return flat; | ||
| } | ||
| function captureBody(body) { | ||
| if (body === void 0 || body === null) return void 0; | ||
| try { | ||
| const str = typeof body === "string" ? body : JSON.stringify(sanitizeObject(body)); | ||
| if (str.length > MAX_BODY_SIZE) { | ||
| return str.slice(0, MAX_BODY_SIZE) + "...[truncated]"; | ||
| } | ||
| return str; | ||
| } catch { | ||
| return void 0; | ||
| } | ||
| } | ||
| function expressRequestHandler() { | ||
@@ -402,5 +460,50 @@ return (req, res, next) => { | ||
| const startTime = Date.now(); | ||
| const reqHeaders = sanitizeHeaders( | ||
| flattenHeaders(req.headers) | ||
| ); | ||
| const reqBody = captureBody(req.body); | ||
| const resChunks = []; | ||
| let resBodySize = 0; | ||
| let resBodyOverflow = false; | ||
| const origWrite = res.write; | ||
| const origEnd = res.end; | ||
| res.write = (chunk, ...args) => { | ||
| if (!resBodyOverflow && chunk) { | ||
| const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)); | ||
| resBodySize += buf.length; | ||
| if (resBodySize <= MAX_BODY_SIZE) { | ||
| resChunks.push(buf); | ||
| } else { | ||
| resBodyOverflow = true; | ||
| } | ||
| } | ||
| return origWrite.apply(res, [chunk, ...args]); | ||
| }; | ||
| res.end = (chunk, ...args) => { | ||
| if (!resBodyOverflow && chunk && typeof chunk !== "function") { | ||
| const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)); | ||
| resBodySize += buf.length; | ||
| if (resBodySize <= MAX_BODY_SIZE) { | ||
| resChunks.push(buf); | ||
| } else { | ||
| resBodyOverflow = true; | ||
| } | ||
| } | ||
| origEnd.apply(res, [chunk, ...args]); | ||
| }; | ||
| res.on("finish", () => { | ||
| try { | ||
| const duration = Date.now() - startTime; | ||
| let resHeaders; | ||
| try { | ||
| resHeaders = flattenHeaders(res.getHeaders()); | ||
| } catch { | ||
| } | ||
| let resBody; | ||
| if (resChunks.length > 0) { | ||
| resBody = Buffer.concat(resChunks).toString("utf-8"); | ||
| if (resBodyOverflow) { | ||
| resBody += "...[truncated]"; | ||
| } | ||
| } | ||
| sendRequest({ | ||
@@ -413,2 +516,6 @@ method: req.method, | ||
| correlationId, | ||
| headers: reqHeaders, | ||
| responseHeaders: resHeaders, | ||
| requestBody: reqBody, | ||
| responseBody: resBody, | ||
| source: "backend" | ||
@@ -415,0 +522,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/index.ts","../../core/src/types/enums.ts","../../core/src/utils/fingerprint.ts","../../core/src/constants.ts","../../core/src/utils/normalize.ts","../../core/src/utils/sanitize.ts","../../core/src/utils/uuid.ts","../../core/src/explanations/patterns.ts","../../core/src/explanations/matcher.ts","../src/config.ts","../src/client.ts","../src/helpers/stack-parser.ts","../src/helpers/environment.ts","../src/instruments/uncaught-exception.ts","../src/instruments/unhandled-rejection.ts","../src/helpers/correlation.ts","../src/instruments/console-error.ts","../src/instruments/memory-monitor.ts","../src/integrations/express.ts","../src/integrations/nextjs.ts"],"sourcesContent":["import type { ErrPulseEvent } from \"@errpulse/core\";\nimport { ErrorType, ErrorSource, Severity, generateEventId } from \"@errpulse/core\";\nimport { configure, getConfig, type NodeSDKConfig } from \"./config.js\";\nimport { enqueueEvent, flushAll } from \"./client.js\";\nimport { installUncaughtExceptionHandler } from \"./instruments/uncaught-exception.js\";\nimport { installUnhandledRejectionHandler } from \"./instruments/unhandled-rejection.js\";\nimport { installConsoleErrorInterceptor } from \"./instruments/console-error.js\";\nimport { installMemoryMonitor } from \"./instruments/memory-monitor.js\";\nimport { parseStack } from \"./helpers/stack-parser.js\";\nimport { getEnvironment } from \"./helpers/environment.js\";\nimport { getCorrelationId } from \"./helpers/correlation.js\";\n\n// Re-exports\nexport { configure, getConfig } from \"./config.js\";\nexport type { NodeSDKConfig } from \"./config.js\";\nexport { expressRequestHandler, expressErrorHandler } from \"./integrations/express.js\";\nexport { withErrPulse } from \"./integrations/nextjs.js\";\nexport { flushAll } from \"./client.js\";\nexport { getCorrelationId } from \"./helpers/correlation.js\";\n\nconst cleanups: (() => void)[] = [];\n\nexport function init(options?: Partial<NodeSDKConfig>): void {\n if (options) configure(options);\n\n const config = getConfig();\n if (!config.enabled) return;\n\n if (config.captureUncaughtExceptions) {\n cleanups.push(installUncaughtExceptionHandler());\n }\n if (config.captureUnhandledRejections) {\n cleanups.push(installUnhandledRejectionHandler());\n }\n if (config.captureConsoleErrors) {\n cleanups.push(installConsoleErrorInterceptor());\n }\n if (config.monitorMemory) {\n cleanups.push(installMemoryMonitor());\n }\n\n // Flush on exit\n process.on(\"beforeExit\", () => {\n flushAll();\n });\n}\n\nexport function captureError(error: Error | string, extra?: Record<string, unknown>): string {\n const err = typeof error === \"string\" ? new Error(error) : error;\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function captureMessage(\n message: string,\n severity: \"info\" | \"warning\" | \"error\" = \"info\",\n extra?: Record<string, unknown>\n): string {\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message,\n source: ErrorSource.Backend,\n severity: severity as Severity,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function close(): void {\n for (const cleanup of cleanups) {\n cleanup();\n }\n cleanups.length = 0;\n flushAll();\n}\n\n// Auto-init with defaults when imported (can be overridden by calling init())\ninit();\n","export enum ErrorSource {\n Backend = \"backend\",\n Frontend = \"frontend\",\n}\n\nexport enum Severity {\n Fatal = \"fatal\",\n Error = \"error\",\n Warning = \"warning\",\n Info = \"info\",\n}\n\nexport enum ErrorType {\n UncaughtException = \"uncaught_exception\",\n UnhandledRejection = \"unhandled_rejection\",\n HttpError = \"http_error\",\n ConsoleError = \"console_error\",\n ReactError = \"react_error\",\n ResourceError = \"resource_error\",\n NetworkError = \"network_error\",\n MemoryWarning = \"memory_warning\",\n Manual = \"manual\",\n}\n\nexport enum ErrorStatus {\n Unresolved = \"unresolved\",\n Acknowledged = \"acknowledged\",\n Resolved = \"resolved\",\n Ignored = \"ignored\",\n}\n","import { createHash } from \"crypto\";\nimport type { ErrPulseEvent, StackFrame } from \"../types/error-event.js\";\nimport { normalizeMessage, getTopFrames } from \"./normalize.js\";\n\nfunction frameKey(frame: StackFrame): string {\n return `${frame.filename}:${frame.function}`;\n}\n\nexport function computeFingerprint(event: ErrPulseEvent): string {\n const parts: string[] = [event.type];\n\n parts.push(normalizeMessage(event.message));\n\n if (event.stackFrames && event.stackFrames.length > 0) {\n const topFrames = getTopFrames(event.stackFrames, 3);\n for (const frame of topFrames) {\n parts.push(frameKey(frame));\n }\n }\n\n const input = parts.join(\"\\n\");\n return createHash(\"sha256\").update(input).digest(\"hex\").slice(0, 32);\n}\n","export const DEFAULT_SERVER_PORT = 3800;\nexport const DEFAULT_DB_DIR = \".errpulse\";\nexport const DEFAULT_DB_FILENAME = \"errpulse.db\";\nexport const DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_SERVER_PORT}`;\nexport const EVENTS_ENDPOINT = \"/api/events\";\nexport const ERRORS_ENDPOINT = \"/api/errors\";\nexport const REQUESTS_ENDPOINT = \"/api/requests\";\nexport const HEALTH_ENDPOINT = \"/api/health\";\nexport const STATS_ENDPOINT = \"/api/stats\";\nexport const CORRELATION_HEADER = \"x-errpulse-correlation-id\";\nexport const PROJECT_HEADER = \"x-errpulse-project-id\";\nexport const MAX_MESSAGE_LENGTH = 2048;\nexport const MAX_STACK_FRAMES = 50;\nexport const BATCH_SIZE = 10;\nexport const BATCH_INTERVAL_MS = 100;\nexport const SENSITIVE_HEADERS = [\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"x-auth-token\",\n];\nexport const SENSITIVE_FIELDS = [\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"apiKey\",\n \"api_key\",\n \"accessToken\",\n \"access_token\",\n \"refreshToken\",\n \"refresh_token\",\n \"creditCard\",\n \"credit_card\",\n \"ssn\",\n \"cardNumber\",\n \"card_number\",\n \"cvv\",\n \"cvc\",\n];\n","import { MAX_MESSAGE_LENGTH, MAX_STACK_FRAMES } from \"../constants.js\";\nimport type { StackFrame } from \"../types/error-event.js\";\n\nexport function normalizeMessage(message: string): string {\n let normalized = message.trim();\n\n // Remove memory addresses (0x1a2b3c4d)\n normalized = normalized.replace(/0x[0-9a-fA-F]+/g, \"0x?\");\n\n // Remove specific line/column numbers from inline references\n normalized = normalized.replace(/:\\d+:\\d+/g, \":?:?\");\n\n // Remove UUIDs\n normalized = normalized.replace(\n /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,\n \"<uuid>\"\n );\n\n // Remove specific port numbers in URLs\n normalized = normalized.replace(/localhost:\\d+/g, \"localhost:?\");\n\n // Remove absolute file paths, keep filename\n normalized = normalized.replace(\n /(?:\\/[\\w.-]+)+\\/([\\w.-]+)/g,\n (_match, filename: string) => `<path>/${filename}`\n );\n\n // Truncate\n if (normalized.length > MAX_MESSAGE_LENGTH) {\n normalized = normalized.slice(0, MAX_MESSAGE_LENGTH) + \"...\";\n }\n\n return normalized;\n}\n\nexport function normalizeStackFrames(frames: StackFrame[]): StackFrame[] {\n return frames.slice(0, MAX_STACK_FRAMES);\n}\n\nexport function getInAppFrames(frames: StackFrame[]): StackFrame[] {\n return frames.filter((f) => f.inApp);\n}\n\nexport function getTopFrames(frames: StackFrame[], count: number): StackFrame[] {\n const inApp = getInAppFrames(frames);\n return inApp.length > 0 ? inApp.slice(0, count) : frames.slice(0, count);\n}\n","import { SENSITIVE_HEADERS, SENSITIVE_FIELDS } from \"../constants.js\";\n\nconst REDACTED = \"[Redacted]\";\n\nexport function sanitizeHeaders(headers: Record<string, string>): Record<string, string> {\n const sanitized: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (SENSITIVE_HEADERS.includes(key.toLowerCase())) {\n sanitized[key] = REDACTED;\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n\nexport function sanitizeObject(obj: unknown): unknown {\n if (obj === null || obj === undefined) return obj;\n if (typeof obj !== \"object\") return obj;\n\n if (Array.isArray(obj)) {\n return obj.map(sanitizeObject);\n }\n\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n if (SENSITIVE_FIELDS.some((f) => key.toLowerCase().includes(f.toLowerCase()))) {\n sanitized[key] = REDACTED;\n } else if (typeof value === \"object\" && value !== null) {\n sanitized[key] = sanitizeObject(value);\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n","import { randomBytes } from \"crypto\";\n\nexport function generateEventId(): string {\n return randomBytes(16).toString(\"hex\");\n}\n\nexport function generateCorrelationId(): string {\n return randomBytes(8).toString(\"hex\");\n}\n","export interface ErrorPattern {\n pattern: RegExp;\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport const ERROR_PATTERNS: ErrorPattern[] = [\n // === Type Errors ===\n {\n pattern: /Cannot read propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Reference Access\",\n explanation:\n \"Your code tried to access a property on something that is undefined or null. This usually means a variable wasn't initialized, an API returned unexpected data, or an object was accessed before it was ready.\",\n suggestion:\n \"Add optional chaining (?.) or a null check before accessing the property. For example: obj?.property instead of obj.property.\",\n },\n {\n pattern: /Cannot set propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Assignment\",\n explanation: \"Your code tried to set a property on something that is undefined or null.\",\n suggestion:\n \"Check that the object exists before assigning to it. Initialize the object first if needed.\",\n },\n {\n pattern: /(\\w+) is not a function/i,\n title: \"Not a Function\",\n explanation:\n \"Your code tried to call something as a function, but it's not one. This often happens when a method name is misspelled, an import is wrong, or a callback wasn't passed correctly.\",\n suggestion:\n \"Check the spelling, verify the import, and make sure the value is actually a function before calling it.\",\n },\n {\n pattern: /(\\w+) is not defined/i,\n title: \"Undefined Variable\",\n explanation:\n \"Your code references a variable that doesn't exist in the current scope. This could be a typo, a missing import, or a scoping issue.\",\n suggestion:\n \"Check for typos in the variable name and ensure it's imported or declared before use.\",\n },\n {\n pattern: /Cannot access '(\\w+)' before initialization/i,\n title: \"Temporal Dead Zone\",\n explanation:\n \"A variable declared with let or const was used before its declaration was reached. JavaScript hoists the declaration but not the initialization.\",\n suggestion:\n \"Move the variable declaration before its first use, or restructure the code to avoid the circular dependency.\",\n },\n {\n pattern: /Assignment to constant variable/i,\n title: \"Constant Reassignment\",\n explanation: \"Your code tried to reassign a variable declared with const.\",\n suggestion: \"Use let instead of const if you need to reassign the variable.\",\n },\n {\n pattern: /Maximum call stack size exceeded/i,\n title: \"Stack Overflow\",\n explanation:\n \"A function called itself recursively without a proper exit condition, causing an infinite loop of calls until the stack ran out of space.\",\n suggestion:\n \"Add or fix the base case in your recursive function. Check for unintended circular calls between functions.\",\n },\n\n // === Syntax / Module Errors ===\n {\n pattern: /Unexpected token/i,\n title: \"Syntax Error\",\n explanation:\n \"The JavaScript parser found a character it didn't expect. This usually means a missing bracket, comma, or quote somewhere.\",\n suggestion:\n \"Check the file around the reported line for missing or extra brackets, commas, semicolons, or quotes.\",\n },\n {\n pattern: /Cannot find module '(.+)'/i,\n title: \"Module Not Found\",\n explanation:\n \"Node.js couldn't find the module you tried to import. Either the package isn't installed, the file path is wrong, or the module name is misspelled.\",\n suggestion:\n \"Run npm install to ensure all dependencies are installed. Check the import path for typos.\",\n },\n {\n pattern: /SyntaxError: .* is not valid JSON/i,\n title: \"Invalid JSON\",\n explanation:\n \"Your code tried to parse a string as JSON, but the string isn't valid JSON. This often happens when an API returns HTML (like an error page) instead of JSON.\",\n suggestion:\n \"Log the raw response before parsing. Check that the API endpoint is correct and returning JSON.\",\n },\n\n // === Network & HTTP Errors ===\n {\n pattern: /ECONNREFUSED/i,\n title: \"Connection Refused\",\n explanation:\n \"Your app tried to connect to a server that isn't accepting connections. The target service is either not running, listening on a different port, or blocked by a firewall.\",\n suggestion: \"Make sure the target service is running and listening on the expected host:port.\",\n },\n {\n pattern: /ECONNRESET/i,\n title: \"Connection Reset\",\n explanation:\n \"The remote server abruptly closed the connection. This can happen due to server crashes, timeouts, or network issues.\",\n suggestion: \"Add retry logic with backoff. Check the remote server's logs for errors.\",\n },\n {\n pattern: /ETIMEDOUT/i,\n title: \"Connection Timed Out\",\n explanation:\n \"The connection to the remote server took too long and was abandoned. The server might be overloaded or unreachable.\",\n suggestion: \"Increase the timeout, check network connectivity, or add retry logic.\",\n },\n {\n pattern: /ENOTFOUND/i,\n title: \"DNS Lookup Failed\",\n explanation:\n \"The hostname couldn't be resolved to an IP address. The domain name is wrong or DNS is not working.\",\n suggestion: \"Check the hostname for typos. Verify DNS resolution is working.\",\n },\n {\n pattern: /EADDRINUSE/i,\n title: \"Port Already in Use\",\n explanation: \"Your app tried to listen on a port that's already taken by another process.\",\n suggestion: \"Use a different port, or find and stop the process using that port: lsof -i :PORT\",\n },\n {\n pattern: /fetch failed|Failed to fetch/i,\n title: \"Fetch Failed\",\n explanation:\n \"A network request failed completely. This usually means the server is unreachable, CORS blocked the request, or there's no internet connection.\",\n suggestion:\n \"Check that the URL is correct, the server is running, and CORS is configured if calling from a browser.\",\n },\n {\n pattern: /Network request failed/i,\n title: \"Network Error\",\n explanation:\n \"A network request could not complete. The server may be down, the URL may be wrong, or the network may be unavailable.\",\n suggestion: \"Verify the target URL and network connectivity.\",\n },\n {\n pattern: /status code 4\\d{2}/i,\n title: \"Client Error (4xx)\",\n explanation:\n \"The server rejected the request due to a client-side issue — bad request data, missing auth, or accessing a resource that doesn't exist.\",\n suggestion: \"Check the request URL, headers, authentication, and body for correctness.\",\n },\n {\n pattern: /status code 5\\d{2}/i,\n title: \"Server Error (5xx)\",\n explanation: \"The server encountered an internal error while processing the request.\",\n suggestion: \"Check the server logs for the root cause. This is a backend issue.\",\n },\n\n // === Database Errors ===\n {\n pattern: /ER_DUP_ENTRY|duplicate key|unique constraint/i,\n title: \"Duplicate Entry\",\n explanation:\n \"A database insert or update violated a unique constraint — you're trying to insert data that already exists.\",\n suggestion: \"Use upsert/ON CONFLICT, or check for existing records before inserting.\",\n },\n {\n pattern: /ER_NO_SUCH_TABLE|relation .* does not exist|no such table/i,\n title: \"Table Not Found\",\n explanation: \"The query references a database table that doesn't exist.\",\n suggestion: \"Run your database migrations. Check that the table name is spelled correctly.\",\n },\n {\n pattern: /ER_PARSE_ERROR|syntax error at or near/i,\n title: \"SQL Syntax Error\",\n explanation: \"Your SQL query has a syntax error.\",\n suggestion: \"Check the SQL query for typos, missing commas, or incorrect keywords.\",\n },\n {\n pattern: /SQLITE_BUSY/i,\n title: \"Database Busy\",\n explanation:\n \"SQLite couldn't acquire a lock because another connection is writing. This happens with concurrent writes.\",\n suggestion: \"Enable WAL mode, reduce write contention, or add retry logic.\",\n },\n {\n pattern: /connection.*refused.*database|Can't connect to/i,\n title: \"Database Connection Failed\",\n explanation:\n \"Your app couldn't connect to the database server. The database might not be running or the connection string is wrong.\",\n suggestion:\n \"Verify the database is running and the connection string (host, port, credentials) is correct.\",\n },\n\n // === React / Frontend Errors ===\n {\n pattern: /Minified React error #(\\d+)/i,\n title: \"React Production Error\",\n explanation:\n \"React threw an error in production mode. The error is minified — check the React error decoder for details.\",\n suggestion:\n \"Look up the error number at https://reactjs.org/docs/error-decoder.html for the full message.\",\n },\n {\n pattern: /Hydration failed|Text content does not match|did not match/i,\n title: \"Hydration Mismatch\",\n explanation:\n \"The HTML rendered on the server doesn't match what React tried to render on the client. This causes the page to re-render completely.\",\n suggestion:\n \"Ensure server and client render identical output. Avoid using Date.now(), Math.random(), or browser-only APIs during initial render.\",\n },\n {\n pattern: /Invalid hook call/i,\n title: \"Invalid React Hook Call\",\n explanation:\n \"A React hook was called outside of a function component, or you have multiple copies of React in your bundle.\",\n suggestion:\n \"Only call hooks at the top level of function components. Check for duplicate React versions with npm ls react.\",\n },\n {\n pattern: /Objects are not valid as a React child/i,\n title: \"Invalid React Child\",\n explanation: \"You tried to render a plain object as a React child, which isn't allowed.\",\n suggestion:\n \"Convert the object to a string (JSON.stringify) or render its properties individually.\",\n },\n {\n pattern: /Each child in a list should have a unique \"key\" prop/i,\n title: \"Missing React Key\",\n explanation:\n \"When rendering a list of elements, each item needs a unique key prop for React's reconciliation algorithm.\",\n suggestion: \"Add a unique key prop to each item. Use a stable ID, not array index.\",\n },\n {\n pattern: /ResizeObserver loop/i,\n title: \"ResizeObserver Loop\",\n explanation:\n \"A ResizeObserver callback caused another resize, creating an infinite loop. This is usually harmless but noisy.\",\n suggestion: \"This is often safe to ignore. If it causes issues, debounce the resize handler.\",\n },\n\n // === Authentication / Authorization ===\n {\n pattern: /jwt (expired|malformed|invalid)/i,\n title: \"JWT Error\",\n explanation:\n \"The JSON Web Token is invalid — it may be expired, malformed, or signed with the wrong key.\",\n suggestion: \"Check token expiration, refresh the token, or verify the signing key matches.\",\n },\n {\n pattern: /unauthorized|401/i,\n title: \"Unauthorized\",\n explanation: \"The request lacks valid authentication credentials.\",\n suggestion: \"Ensure the auth token is present and valid. Check for expired sessions.\",\n },\n {\n pattern: /forbidden|403/i,\n title: \"Forbidden\",\n explanation:\n \"The server understood the request but refuses to authorize it. The user doesn't have permission.\",\n suggestion: \"Check user permissions and roles. Verify the user has access to this resource.\",\n },\n\n // === CORS ===\n {\n pattern: /CORS|Access-Control-Allow-Origin|cross-origin/i,\n title: \"CORS Error\",\n explanation:\n \"The browser blocked a request to a different origin because the server didn't include the right CORS headers.\",\n suggestion:\n \"Configure the server to send Access-Control-Allow-Origin headers. For development, use a proxy or cors middleware.\",\n },\n\n // === Memory ===\n {\n pattern: /heap out of memory|ENOMEM|JavaScript heap/i,\n title: \"Out of Memory\",\n explanation:\n \"The process ran out of available memory. This could be a memory leak or processing too much data at once.\",\n suggestion:\n \"Increase memory limit with --max-old-space-size, check for memory leaks, or process data in chunks.\",\n },\n {\n pattern: /memory usage.*threshold|high memory/i,\n title: \"High Memory Usage\",\n explanation: \"The application's memory usage has exceeded the warning threshold.\",\n suggestion:\n \"Monitor for memory leaks. Consider restarting the process periodically or increasing available memory.\",\n },\n\n // === File System ===\n {\n pattern: /ENOENT|no such file or directory/i,\n title: \"File Not Found\",\n explanation: \"Your code tried to access a file or directory that doesn't exist.\",\n suggestion: \"Check the file path for typos. Ensure the file exists before accessing it.\",\n },\n {\n pattern: /EACCES|permission denied/i,\n title: \"Permission Denied\",\n explanation: \"The process doesn't have permission to access the file or resource.\",\n suggestion: \"Check file permissions. Run with appropriate user/group or fix file ownership.\",\n },\n {\n pattern: /EMFILE|too many open files/i,\n title: \"Too Many Open Files\",\n explanation:\n \"The process has opened more files than the OS allows. This often indicates a file descriptor leak.\",\n suggestion: \"Close files after use. Increase the ulimit, or check for leaked file descriptors.\",\n },\n\n // === Timeout ===\n {\n pattern: /timeout|timed out|ESOCKETTIMEDOUT/i,\n title: \"Operation Timed Out\",\n explanation:\n \"An operation took too long and was cancelled. The target service might be slow or overloaded.\",\n suggestion:\n \"Increase the timeout value, add retry logic, or investigate why the operation is slow.\",\n },\n\n // === Encoding / Parsing ===\n {\n pattern: /URIError|URI malformed/i,\n title: \"Malformed URI\",\n explanation: \"A URL encoding/decoding operation received an invalid URI.\",\n suggestion:\n \"Check the input for invalid characters. Use encodeURIComponent/decodeURIComponent correctly.\",\n },\n {\n pattern: /RangeError.*Invalid array length/i,\n title: \"Invalid Array Length\",\n explanation: \"An array was created with an invalid length (negative or too large).\",\n suggestion: \"Check the value being used as the array length.\",\n },\n\n // === Catch-all ===\n {\n pattern: /TypeError/i,\n title: \"Type Error\",\n explanation:\n \"A value is not the type that was expected. This often means using the wrong method on the wrong data type.\",\n suggestion:\n \"Check what type the variable actually is (using typeof or console.log) and handle it appropriately.\",\n },\n {\n pattern: /ReferenceError/i,\n title: \"Reference Error\",\n explanation: \"Your code references something that doesn't exist in the current scope.\",\n suggestion: \"Check for typos, missing imports, or variables used outside their scope.\",\n },\n {\n pattern: /SyntaxError/i,\n title: \"Syntax Error\",\n explanation: \"The code has a syntax error that prevents it from being parsed.\",\n suggestion:\n \"Check for missing brackets, quotes, commas, or other syntax issues around the reported location.\",\n },\n];\n","import { ERROR_PATTERNS, type ErrorPattern } from \"./patterns.js\";\n\nexport interface ErrorExplanation {\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport function explainError(message: string): ErrorExplanation | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return {\n title: pattern.title,\n explanation: pattern.explanation,\n suggestion: pattern.suggestion,\n };\n }\n }\n return null;\n}\n\nexport function matchPattern(message: string): ErrorPattern | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return pattern;\n }\n }\n return null;\n}\n","import { DEFAULT_SERVER_URL } from \"@errpulse/core\";\nimport type { ErrPulseEvent } from \"@errpulse/core\";\n\nexport interface NodeSDKConfig {\n serverUrl: string;\n projectId?: string;\n enabled: boolean;\n sampleRate: number;\n beforeSend?: (event: ErrPulseEvent) => ErrPulseEvent | null;\n captureConsoleErrors: boolean;\n captureUncaughtExceptions: boolean;\n captureUnhandledRejections: boolean;\n monitorMemory: boolean;\n memoryThresholdMB: number;\n memoryCheckIntervalMs: number;\n}\n\nconst defaultConfig: NodeSDKConfig = {\n serverUrl: DEFAULT_SERVER_URL,\n enabled: true,\n sampleRate: 1.0,\n captureConsoleErrors: true,\n captureUncaughtExceptions: true,\n captureUnhandledRejections: true,\n monitorMemory: true,\n memoryThresholdMB: 512,\n memoryCheckIntervalMs: 30000,\n};\n\nlet currentConfig: NodeSDKConfig = { ...defaultConfig };\n\nexport function configure(partial: Partial<NodeSDKConfig>): NodeSDKConfig {\n currentConfig = { ...currentConfig, ...partial };\n return currentConfig;\n}\n\nexport function getConfig(): NodeSDKConfig {\n return currentConfig;\n}\n","import { EVENTS_ENDPOINT, BATCH_SIZE, BATCH_INTERVAL_MS, type ErrPulseEvent } from \"@errpulse/core\";\nimport { getConfig } from \"./config.js\";\n\nlet buffer: ErrPulseEvent[] = [];\nlet flushTimer: ReturnType<typeof setTimeout> | null = null;\nlet isFlushing = false;\n\nasync function sendBatch(events: ErrPulseEvent[]): Promise<void> {\n const config = getConfig();\n if (!config.enabled || events.length === 0) return;\n\n const url =\n events.length === 1\n ? `${config.serverUrl}${EVENTS_ENDPOINT}`\n : `${config.serverUrl}${EVENTS_ENDPOINT}/batch`;\n const body = events.length === 1 ? events[0] : events;\n\n try {\n const resp = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(5000),\n });\n\n if (!resp.ok) {\n console.warn(`[ErrPulse] Failed to send events: ${resp.status}`);\n }\n } catch {\n // Silently fail — SDK must never crash host app\n }\n}\n\nfunction scheduleFlush(): void {\n if (flushTimer) return;\n flushTimer = setTimeout(() => {\n flushTimer = null;\n flush();\n }, BATCH_INTERVAL_MS);\n}\n\nasync function flush(): Promise<void> {\n if (isFlushing || buffer.length === 0) return;\n isFlushing = true;\n\n const batch = buffer.splice(0);\n await sendBatch(batch);\n\n isFlushing = false;\n\n // If more events accumulated during flush, schedule another\n if (buffer.length > 0) {\n scheduleFlush();\n }\n}\n\nexport function enqueueEvent(event: ErrPulseEvent): void {\n const config = getConfig();\n if (!config.enabled) return;\n\n // Sample rate check\n if (config.sampleRate < 1 && Math.random() > config.sampleRate) return;\n\n // Inject projectId\n if (config.projectId && !event.projectId) {\n event.projectId = config.projectId;\n }\n\n // beforeSend hook\n if (config.beforeSend) {\n const result = config.beforeSend(event);\n if (!result) return;\n buffer.push(result);\n } else {\n buffer.push(event);\n }\n\n if (buffer.length >= BATCH_SIZE) {\n flush();\n } else {\n scheduleFlush();\n }\n}\n\nexport async function flushAll(): Promise<void> {\n if (flushTimer) {\n clearTimeout(flushTimer);\n flushTimer = null;\n }\n await flush();\n}\n\n// Send a request log entry\nexport async function sendRequest(entry: {\n method: string;\n url: string;\n statusCode?: number;\n duration?: number;\n timestamp: string;\n correlationId?: string;\n errorEventId?: string;\n source?: string;\n projectId?: string;\n}): Promise<void> {\n const config = getConfig();\n if (!config.enabled) return;\n\n const payload = {\n ...entry,\n projectId: entry.projectId ?? config.projectId,\n };\n\n try {\n await fetch(`${config.serverUrl}${EVENTS_ENDPOINT}/request`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(5000),\n });\n } catch {\n // Silently fail\n }\n}\n","import type { StackFrame } from \"@errpulse/core\";\n\nconst NODE_STACK_RE = /^\\s*at\\s+(?:(.+?)\\s+\\()?(.+?):(\\d+):(\\d+)\\)?$/;\n\nexport function parseStack(stack: string): StackFrame[] {\n const frames: StackFrame[] = [];\n\n for (const line of stack.split(\"\\n\")) {\n const match = NODE_STACK_RE.exec(line);\n if (!match) continue;\n\n const [, fn, filename, lineno, colno] = match;\n\n const isNodeInternal =\n filename.startsWith(\"node:\") ||\n filename.includes(\"node_modules\") ||\n !filename.startsWith(\"/\");\n\n frames.push({\n function: fn || \"<anonymous>\",\n filename,\n lineno: Number(lineno),\n colno: Number(colno),\n inApp: !isNodeInternal,\n });\n }\n\n return frames;\n}\n","import type { EnvironmentInfo } from \"@errpulse/core\";\nimport os from \"os\";\n\nexport function getEnvironment(): EnvironmentInfo {\n const mem = process.memoryUsage();\n return {\n runtime: \"node\",\n runtimeVersion: process.version,\n nodeVersion: process.version,\n os: `${os.type()} ${os.release()}`,\n arch: os.arch(),\n memoryUsage: {\n heapUsed: mem.heapUsed,\n heapTotal: mem.heapTotal,\n rss: mem.rss,\n },\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, flushAll } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUncaughtExceptionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = async (error: Error) => {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UncaughtException,\n message: error.message || String(error),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Fatal,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n await flushAll();\n };\n\n process.on(\"uncaughtException\", handler);\n\n return () => {\n process.removeListener(\"uncaughtException\", handler);\n installed = false;\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUnhandledRejectionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = (reason: unknown) => {\n const error = reason instanceof Error ? reason : new Error(String(reason));\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UnhandledRejection,\n message: error.message || String(reason),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n };\n\n process.on(\"unhandledRejection\", handler);\n\n return () => {\n process.removeListener(\"unhandledRejection\", handler);\n installed = false;\n };\n}\n","import { AsyncLocalStorage } from \"async_hooks\";\nimport { CORRELATION_HEADER, generateCorrelationId } from \"@errpulse/core\";\n\nconst correlationStore = new AsyncLocalStorage<string>();\n\nexport function getCorrelationId(): string | undefined {\n return correlationStore.getStore();\n}\n\nexport function runWithCorrelation<T>(correlationId: string, fn: () => T): T {\n return correlationStore.run(correlationId, fn);\n}\n\nexport function extractOrCreateCorrelationId(\n headers: Record<string, string | string[] | undefined>\n): string {\n const existing = headers[CORRELATION_HEADER];\n if (typeof existing === \"string\" && existing) {\n return existing;\n }\n return generateCorrelationId();\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getCorrelationId } from \"../helpers/correlation.js\";\n\nlet originalConsoleError: typeof console.error | null = null;\n\nexport function installConsoleErrorInterceptor(): () => void {\n if (originalConsoleError) return () => {};\n\n originalConsoleError = console.error;\n\n console.error = (...args: unknown[]) => {\n // Always call original\n originalConsoleError!.apply(console, args);\n\n try {\n const message = args.map((a) => (typeof a === \"string\" ? a : JSON.stringify(a))).join(\" \");\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.ConsoleError,\n message,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash the host app\n }\n };\n\n return () => {\n if (originalConsoleError) {\n console.error = originalConsoleError;\n originalConsoleError = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getConfig } from \"../config.js\";\n\nlet intervalId: ReturnType<typeof setInterval> | null = null;\n\nexport function installMemoryMonitor(): () => void {\n if (intervalId) return () => {};\n\n const config = getConfig();\n\n intervalId = setInterval(() => {\n try {\n const mem = process.memoryUsage();\n const heapUsedMB = mem.heapUsed / (1024 * 1024);\n\n if (heapUsedMB > config.memoryThresholdMB) {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.MemoryWarning,\n message: `High memory usage: ${Math.round(heapUsedMB)}MB heap used (threshold: ${config.memoryThresholdMB}MB)`,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n extra: {\n heapUsedMB: Math.round(heapUsedMB),\n heapTotalMB: Math.round(mem.heapTotal / (1024 * 1024)),\n rssMB: Math.round(mem.rss / (1024 * 1024)),\n threshold: config.memoryThresholdMB,\n },\n };\n\n enqueueEvent(event);\n }\n } catch {\n // Never crash host app\n }\n }, config.memoryCheckIntervalMs);\n\n return () => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n sanitizeHeaders,\n CORRELATION_HEADER,\n type ErrPulseEvent,\n type RequestContext,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { extractOrCreateCorrelationId, runWithCorrelation } from \"../helpers/correlation.js\";\n\ntype Request = {\n method: string;\n url: string;\n originalUrl?: string;\n path?: string;\n headers: Record<string, string | string[] | undefined>;\n query?: Record<string, string>;\n body?: unknown;\n ip?: string;\n};\n\ntype Response = {\n statusCode: number;\n on(event: string, listener: () => void): void;\n};\n\ntype NextFunction = (err?: unknown) => void;\n\nexport function expressRequestHandler() {\n return (req: Request, res: Response, next: NextFunction): void => {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n const startTime = Date.now();\n\n // Track response completion to log request\n res.on(\"finish\", () => {\n try {\n const duration = Date.now() - startTime;\n sendRequest({\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n } catch {\n // Never crash host app\n }\n });\n\n // Run the rest of the middleware chain with correlation context\n runWithCorrelation(correlationId, () => next());\n };\n}\n\nexport function expressErrorHandler() {\n return (err: Error, req: Request, res: Response, next: NextFunction): void => {\n try {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n\n const requestContext: RequestContext = {\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode >= 400 ? res.statusCode : 500,\n headers: sanitizeHeaders(\n Object.fromEntries(\n Object.entries(req.headers).map(([k, v]) => [\n k,\n Array.isArray(v) ? v.join(\", \") : v || \"\",\n ])\n )\n ),\n query: req.query as Record<string, string>,\n ip: req.ip,\n userAgent: req.headers[\"user-agent\"] as string,\n };\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: requestContext,\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash host app\n }\n\n next(err);\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n CORRELATION_HEADER,\n generateCorrelationId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\ntype NextRequest = {\n method: string;\n url: string;\n headers: { get(name: string): string | null };\n nextUrl?: { pathname: string };\n};\n\ntype NextResponse = {\n status: number;\n};\n\n/**\n * Wraps a Next.js API route handler to capture errors and log requests.\n *\n * Usage:\n * import { withErrPulse } from '@errpulse/node'\n * export const GET = withErrPulse(async (req) => { ... })\n */\nexport function withErrPulse<T extends (...args: unknown[]) => Promise<unknown>>(handler: T): T {\n return (async (...args: unknown[]) => {\n const req = args[0] as NextRequest | undefined;\n const method = req?.method ?? \"UNKNOWN\";\n const url = req?.nextUrl?.pathname ?? req?.url ?? \"/\";\n const correlationId = req?.headers?.get(CORRELATION_HEADER) ?? generateCorrelationId();\n const startTime = Date.now();\n\n try {\n const result = await handler(...args);\n const duration = Date.now() - startTime;\n\n // Log the request\n const statusCode = (result as NextResponse)?.status ?? 200;\n sendRequest({\n method,\n url,\n statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n return result;\n } catch (error) {\n const duration = Date.now() - startTime;\n const err = error instanceof Error ? error : new Error(String(error));\n\n // Log the failed request\n sendRequest({\n method,\n url,\n statusCode: 500,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n // Capture the error\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: {\n method,\n url,\n statusCode: 500,\n duration,\n },\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n throw error;\n }\n }) as T;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AMAA,oBAA4B;ALArB,IAAK,cAAL,kBAAKA,iBAAL;AACLA,eAAA,SAAA,IAAU;AACVA,eAAA,UAAA,IAAW;AAFD,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAKL,IAAK,WAAL,kBAAKC,cAAL;AACLA,YAAA,OAAA,IAAQ;AACRA,YAAA,OAAA,IAAQ;AACRA,YAAA,SAAA,IAAU;AACVA,YAAA,MAAA,IAAO;AAJG,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAOL,IAAK,YAAL,kBAAKC,eAAL;AACLA,aAAA,mBAAA,IAAoB;AACpBA,aAAA,oBAAA,IAAqB;AACrBA,aAAA,WAAA,IAAY;AACZA,aAAA,cAAA,IAAe;AACfA,aAAA,YAAA,IAAa;AACbA,aAAA,eAAA,IAAgB;AAChBA,aAAA,cAAA,IAAe;AACfA,aAAA,eAAA,IAAgB;AAChBA,aAAA,QAAA,IAAS;AATC,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AEZL,IAAM,sBAAsB;AAG5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A,IACpB;AAAA,IACA,aAAa,eAAe;AAAA,IAC5B,eAAe,iBAAiB;AAAA,IAChC,WAAW,UAAU,EAAE;AAAA,IACvB;AAAA,EACF;AAEA,eAAa,KAAK;AAClB,SAAO;AACT;AAEO,SAAS,QAAc;AAC5B,aAAW,WAAW,UAAU;AAC9B,YAAQ;AAAA,EACV;AACA,WAAS,SAAS;AAClB,WAAS;AACX;AAGA,KAAK;","names":["ErrorSource","Severity","ErrorType","os","installed"]} | ||
| {"version":3,"sources":["../src/index.ts","../../core/src/types/enums.ts","../../core/src/utils/fingerprint.ts","../../core/src/constants.ts","../../core/src/utils/normalize.ts","../../core/src/utils/sanitize.ts","../../core/src/utils/uuid.ts","../../core/src/explanations/patterns.ts","../../core/src/explanations/matcher.ts","../src/config.ts","../src/client.ts","../src/helpers/stack-parser.ts","../src/helpers/environment.ts","../src/instruments/uncaught-exception.ts","../src/instruments/unhandled-rejection.ts","../src/helpers/correlation.ts","../src/instruments/console-error.ts","../src/instruments/memory-monitor.ts","../src/integrations/express.ts","../src/integrations/nextjs.ts"],"sourcesContent":["import type { ErrPulseEvent } from \"@errpulse/core\";\nimport { ErrorType, ErrorSource, Severity, generateEventId } from \"@errpulse/core\";\nimport { configure, getConfig, type NodeSDKConfig } from \"./config.js\";\nimport { enqueueEvent, flushAll } from \"./client.js\";\nimport { installUncaughtExceptionHandler } from \"./instruments/uncaught-exception.js\";\nimport { installUnhandledRejectionHandler } from \"./instruments/unhandled-rejection.js\";\nimport { installConsoleErrorInterceptor } from \"./instruments/console-error.js\";\nimport { installMemoryMonitor } from \"./instruments/memory-monitor.js\";\nimport { parseStack } from \"./helpers/stack-parser.js\";\nimport { getEnvironment } from \"./helpers/environment.js\";\nimport { getCorrelationId } from \"./helpers/correlation.js\";\n\n// Re-exports\nexport { configure, getConfig } from \"./config.js\";\nexport type { NodeSDKConfig } from \"./config.js\";\nexport { expressRequestHandler, expressErrorHandler } from \"./integrations/express.js\";\nexport { withErrPulse } from \"./integrations/nextjs.js\";\nexport { flushAll } from \"./client.js\";\nexport { getCorrelationId } from \"./helpers/correlation.js\";\n\nconst cleanups: (() => void)[] = [];\n\nexport function init(options?: Partial<NodeSDKConfig>): void {\n if (options) configure(options);\n\n const config = getConfig();\n if (!config.enabled) return;\n\n if (config.captureUncaughtExceptions) {\n cleanups.push(installUncaughtExceptionHandler());\n }\n if (config.captureUnhandledRejections) {\n cleanups.push(installUnhandledRejectionHandler());\n }\n if (config.captureConsoleErrors) {\n cleanups.push(installConsoleErrorInterceptor());\n }\n if (config.monitorMemory) {\n cleanups.push(installMemoryMonitor());\n }\n\n // Flush on exit\n process.on(\"beforeExit\", () => {\n flushAll();\n });\n}\n\nexport function captureError(error: Error | string, extra?: Record<string, unknown>): string {\n const err = typeof error === \"string\" ? new Error(error) : error;\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function captureMessage(\n message: string,\n severity: \"info\" | \"warning\" | \"error\" = \"info\",\n extra?: Record<string, unknown>\n): string {\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message,\n source: ErrorSource.Backend,\n severity: severity as Severity,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function close(): void {\n for (const cleanup of cleanups) {\n cleanup();\n }\n cleanups.length = 0;\n flushAll();\n}\n\n// Auto-init with defaults when imported (can be overridden by calling init())\ninit();\n","export enum ErrorSource {\n Backend = \"backend\",\n Frontend = \"frontend\",\n}\n\nexport enum Severity {\n Fatal = \"fatal\",\n Error = \"error\",\n Warning = \"warning\",\n Info = \"info\",\n}\n\nexport enum ErrorType {\n UncaughtException = \"uncaught_exception\",\n UnhandledRejection = \"unhandled_rejection\",\n HttpError = \"http_error\",\n ConsoleError = \"console_error\",\n ReactError = \"react_error\",\n ResourceError = \"resource_error\",\n NetworkError = \"network_error\",\n MemoryWarning = \"memory_warning\",\n Manual = \"manual\",\n}\n\nexport enum ErrorStatus {\n Unresolved = \"unresolved\",\n Acknowledged = \"acknowledged\",\n Resolved = \"resolved\",\n Ignored = \"ignored\",\n}\n","import { createHash } from \"crypto\";\nimport type { ErrPulseEvent, StackFrame } from \"../types/error-event.js\";\nimport { normalizeMessage, getTopFrames } from \"./normalize.js\";\n\nfunction frameKey(frame: StackFrame): string {\n return `${frame.filename}:${frame.function}`;\n}\n\nexport function computeFingerprint(event: ErrPulseEvent): string {\n const parts: string[] = [event.type];\n\n parts.push(normalizeMessage(event.message));\n\n if (event.stackFrames && event.stackFrames.length > 0) {\n const topFrames = getTopFrames(event.stackFrames, 3);\n for (const frame of topFrames) {\n parts.push(frameKey(frame));\n }\n }\n\n const input = parts.join(\"\\n\");\n return createHash(\"sha256\").update(input).digest(\"hex\").slice(0, 32);\n}\n","export const DEFAULT_SERVER_PORT = 3800;\nexport const DEFAULT_DB_DIR = \".errpulse\";\nexport const DEFAULT_DB_FILENAME = \"errpulse.db\";\nexport const DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_SERVER_PORT}`;\nexport const EVENTS_ENDPOINT = \"/api/events\";\nexport const ERRORS_ENDPOINT = \"/api/errors\";\nexport const REQUESTS_ENDPOINT = \"/api/requests\";\nexport const HEALTH_ENDPOINT = \"/api/health\";\nexport const STATS_ENDPOINT = \"/api/stats\";\nexport const CORRELATION_HEADER = \"x-errpulse-correlation-id\";\nexport const PROJECT_HEADER = \"x-errpulse-project-id\";\nexport const MAX_MESSAGE_LENGTH = 2048;\nexport const MAX_STACK_FRAMES = 50;\nexport const BATCH_SIZE = 10;\nexport const BATCH_INTERVAL_MS = 100;\nexport const SENSITIVE_HEADERS = [\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"x-auth-token\",\n];\nexport const SENSITIVE_FIELDS = [\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"apiKey\",\n \"api_key\",\n \"accessToken\",\n \"access_token\",\n \"refreshToken\",\n \"refresh_token\",\n \"creditCard\",\n \"credit_card\",\n \"ssn\",\n \"cardNumber\",\n \"card_number\",\n \"cvv\",\n \"cvc\",\n];\n","import { MAX_MESSAGE_LENGTH, MAX_STACK_FRAMES } from \"../constants.js\";\nimport type { StackFrame } from \"../types/error-event.js\";\n\nexport function normalizeMessage(message: string): string {\n let normalized = message.trim();\n\n // Remove memory addresses (0x1a2b3c4d)\n normalized = normalized.replace(/0x[0-9a-fA-F]+/g, \"0x?\");\n\n // Remove specific line/column numbers from inline references\n normalized = normalized.replace(/:\\d+:\\d+/g, \":?:?\");\n\n // Remove UUIDs\n normalized = normalized.replace(\n /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,\n \"<uuid>\"\n );\n\n // Remove specific port numbers in URLs\n normalized = normalized.replace(/localhost:\\d+/g, \"localhost:?\");\n\n // Remove absolute file paths, keep filename\n normalized = normalized.replace(\n /(?:\\/[\\w.-]+)+\\/([\\w.-]+)/g,\n (_match, filename: string) => `<path>/${filename}`\n );\n\n // Truncate\n if (normalized.length > MAX_MESSAGE_LENGTH) {\n normalized = normalized.slice(0, MAX_MESSAGE_LENGTH) + \"...\";\n }\n\n return normalized;\n}\n\nexport function normalizeStackFrames(frames: StackFrame[]): StackFrame[] {\n return frames.slice(0, MAX_STACK_FRAMES);\n}\n\nexport function getInAppFrames(frames: StackFrame[]): StackFrame[] {\n return frames.filter((f) => f.inApp);\n}\n\nexport function getTopFrames(frames: StackFrame[], count: number): StackFrame[] {\n const inApp = getInAppFrames(frames);\n return inApp.length > 0 ? inApp.slice(0, count) : frames.slice(0, count);\n}\n","import { SENSITIVE_HEADERS, SENSITIVE_FIELDS } from \"../constants.js\";\n\nconst REDACTED = \"[Redacted]\";\n\nexport function sanitizeHeaders(headers: Record<string, string>): Record<string, string> {\n const sanitized: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (SENSITIVE_HEADERS.includes(key.toLowerCase())) {\n sanitized[key] = REDACTED;\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n\nexport function sanitizeObject(obj: unknown): unknown {\n if (obj === null || obj === undefined) return obj;\n if (typeof obj !== \"object\") return obj;\n\n if (Array.isArray(obj)) {\n return obj.map(sanitizeObject);\n }\n\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n if (SENSITIVE_FIELDS.some((f) => key.toLowerCase().includes(f.toLowerCase()))) {\n sanitized[key] = REDACTED;\n } else if (typeof value === \"object\" && value !== null) {\n sanitized[key] = sanitizeObject(value);\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n","import { randomBytes } from \"crypto\";\n\nexport function generateEventId(): string {\n return randomBytes(16).toString(\"hex\");\n}\n\nexport function generateCorrelationId(): string {\n return randomBytes(8).toString(\"hex\");\n}\n","export interface ErrorPattern {\n pattern: RegExp;\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport const ERROR_PATTERNS: ErrorPattern[] = [\n // === Type Errors ===\n {\n pattern: /Cannot read propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Reference Access\",\n explanation:\n \"Your code tried to access a property on something that is undefined or null. This usually means a variable wasn't initialized, an API returned unexpected data, or an object was accessed before it was ready.\",\n suggestion:\n \"Add optional chaining (?.) or a null check before accessing the property. For example: obj?.property instead of obj.property.\",\n },\n {\n pattern: /Cannot set propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Assignment\",\n explanation: \"Your code tried to set a property on something that is undefined or null.\",\n suggestion:\n \"Check that the object exists before assigning to it. Initialize the object first if needed.\",\n },\n {\n pattern: /(\\w+) is not a function/i,\n title: \"Not a Function\",\n explanation:\n \"Your code tried to call something as a function, but it's not one. This often happens when a method name is misspelled, an import is wrong, or a callback wasn't passed correctly.\",\n suggestion:\n \"Check the spelling, verify the import, and make sure the value is actually a function before calling it.\",\n },\n {\n pattern: /(\\w+) is not defined/i,\n title: \"Undefined Variable\",\n explanation:\n \"Your code references a variable that doesn't exist in the current scope. This could be a typo, a missing import, or a scoping issue.\",\n suggestion:\n \"Check for typos in the variable name and ensure it's imported or declared before use.\",\n },\n {\n pattern: /Cannot access '(\\w+)' before initialization/i,\n title: \"Temporal Dead Zone\",\n explanation:\n \"A variable declared with let or const was used before its declaration was reached. JavaScript hoists the declaration but not the initialization.\",\n suggestion:\n \"Move the variable declaration before its first use, or restructure the code to avoid the circular dependency.\",\n },\n {\n pattern: /Assignment to constant variable/i,\n title: \"Constant Reassignment\",\n explanation: \"Your code tried to reassign a variable declared with const.\",\n suggestion: \"Use let instead of const if you need to reassign the variable.\",\n },\n {\n pattern: /Maximum call stack size exceeded/i,\n title: \"Stack Overflow\",\n explanation:\n \"A function called itself recursively without a proper exit condition, causing an infinite loop of calls until the stack ran out of space.\",\n suggestion:\n \"Add or fix the base case in your recursive function. Check for unintended circular calls between functions.\",\n },\n\n // === Syntax / Module Errors ===\n {\n pattern: /Unexpected token/i,\n title: \"Syntax Error\",\n explanation:\n \"The JavaScript parser found a character it didn't expect. This usually means a missing bracket, comma, or quote somewhere.\",\n suggestion:\n \"Check the file around the reported line for missing or extra brackets, commas, semicolons, or quotes.\",\n },\n {\n pattern: /Cannot find module '(.+)'/i,\n title: \"Module Not Found\",\n explanation:\n \"Node.js couldn't find the module you tried to import. Either the package isn't installed, the file path is wrong, or the module name is misspelled.\",\n suggestion:\n \"Run npm install to ensure all dependencies are installed. Check the import path for typos.\",\n },\n {\n pattern: /SyntaxError: .* is not valid JSON/i,\n title: \"Invalid JSON\",\n explanation:\n \"Your code tried to parse a string as JSON, but the string isn't valid JSON. This often happens when an API returns HTML (like an error page) instead of JSON.\",\n suggestion:\n \"Log the raw response before parsing. Check that the API endpoint is correct and returning JSON.\",\n },\n\n // === Network & HTTP Errors ===\n {\n pattern: /ECONNREFUSED/i,\n title: \"Connection Refused\",\n explanation:\n \"Your app tried to connect to a server that isn't accepting connections. The target service is either not running, listening on a different port, or blocked by a firewall.\",\n suggestion: \"Make sure the target service is running and listening on the expected host:port.\",\n },\n {\n pattern: /ECONNRESET/i,\n title: \"Connection Reset\",\n explanation:\n \"The remote server abruptly closed the connection. This can happen due to server crashes, timeouts, or network issues.\",\n suggestion: \"Add retry logic with backoff. Check the remote server's logs for errors.\",\n },\n {\n pattern: /ETIMEDOUT/i,\n title: \"Connection Timed Out\",\n explanation:\n \"The connection to the remote server took too long and was abandoned. The server might be overloaded or unreachable.\",\n suggestion: \"Increase the timeout, check network connectivity, or add retry logic.\",\n },\n {\n pattern: /ENOTFOUND/i,\n title: \"DNS Lookup Failed\",\n explanation:\n \"The hostname couldn't be resolved to an IP address. The domain name is wrong or DNS is not working.\",\n suggestion: \"Check the hostname for typos. Verify DNS resolution is working.\",\n },\n {\n pattern: /EADDRINUSE/i,\n title: \"Port Already in Use\",\n explanation: \"Your app tried to listen on a port that's already taken by another process.\",\n suggestion: \"Use a different port, or find and stop the process using that port: lsof -i :PORT\",\n },\n {\n pattern: /fetch failed|Failed to fetch/i,\n title: \"Fetch Failed\",\n explanation:\n \"A network request failed completely. This usually means the server is unreachable, CORS blocked the request, or there's no internet connection.\",\n suggestion:\n \"Check that the URL is correct, the server is running, and CORS is configured if calling from a browser.\",\n },\n {\n pattern: /Network request failed/i,\n title: \"Network Error\",\n explanation:\n \"A network request could not complete. The server may be down, the URL may be wrong, or the network may be unavailable.\",\n suggestion: \"Verify the target URL and network connectivity.\",\n },\n {\n pattern: /status code 4\\d{2}/i,\n title: \"Client Error (4xx)\",\n explanation:\n \"The server rejected the request due to a client-side issue — bad request data, missing auth, or accessing a resource that doesn't exist.\",\n suggestion: \"Check the request URL, headers, authentication, and body for correctness.\",\n },\n {\n pattern: /status code 5\\d{2}/i,\n title: \"Server Error (5xx)\",\n explanation: \"The server encountered an internal error while processing the request.\",\n suggestion: \"Check the server logs for the root cause. This is a backend issue.\",\n },\n\n // === Database Errors ===\n {\n pattern: /ER_DUP_ENTRY|duplicate key|unique constraint/i,\n title: \"Duplicate Entry\",\n explanation:\n \"A database insert or update violated a unique constraint — you're trying to insert data that already exists.\",\n suggestion: \"Use upsert/ON CONFLICT, or check for existing records before inserting.\",\n },\n {\n pattern: /ER_NO_SUCH_TABLE|relation .* does not exist|no such table/i,\n title: \"Table Not Found\",\n explanation: \"The query references a database table that doesn't exist.\",\n suggestion: \"Run your database migrations. Check that the table name is spelled correctly.\",\n },\n {\n pattern: /ER_PARSE_ERROR|syntax error at or near/i,\n title: \"SQL Syntax Error\",\n explanation: \"Your SQL query has a syntax error.\",\n suggestion: \"Check the SQL query for typos, missing commas, or incorrect keywords.\",\n },\n {\n pattern: /SQLITE_BUSY/i,\n title: \"Database Busy\",\n explanation:\n \"SQLite couldn't acquire a lock because another connection is writing. This happens with concurrent writes.\",\n suggestion: \"Enable WAL mode, reduce write contention, or add retry logic.\",\n },\n {\n pattern: /connection.*refused.*database|Can't connect to/i,\n title: \"Database Connection Failed\",\n explanation:\n \"Your app couldn't connect to the database server. The database might not be running or the connection string is wrong.\",\n suggestion:\n \"Verify the database is running and the connection string (host, port, credentials) is correct.\",\n },\n\n // === React / Frontend Errors ===\n {\n pattern: /Minified React error #(\\d+)/i,\n title: \"React Production Error\",\n explanation:\n \"React threw an error in production mode. The error is minified — check the React error decoder for details.\",\n suggestion:\n \"Look up the error number at https://reactjs.org/docs/error-decoder.html for the full message.\",\n },\n {\n pattern: /Hydration failed|Text content does not match|did not match/i,\n title: \"Hydration Mismatch\",\n explanation:\n \"The HTML rendered on the server doesn't match what React tried to render on the client. This causes the page to re-render completely.\",\n suggestion:\n \"Ensure server and client render identical output. Avoid using Date.now(), Math.random(), or browser-only APIs during initial render.\",\n },\n {\n pattern: /Invalid hook call/i,\n title: \"Invalid React Hook Call\",\n explanation:\n \"A React hook was called outside of a function component, or you have multiple copies of React in your bundle.\",\n suggestion:\n \"Only call hooks at the top level of function components. Check for duplicate React versions with npm ls react.\",\n },\n {\n pattern: /Objects are not valid as a React child/i,\n title: \"Invalid React Child\",\n explanation: \"You tried to render a plain object as a React child, which isn't allowed.\",\n suggestion:\n \"Convert the object to a string (JSON.stringify) or render its properties individually.\",\n },\n {\n pattern: /Each child in a list should have a unique \"key\" prop/i,\n title: \"Missing React Key\",\n explanation:\n \"When rendering a list of elements, each item needs a unique key prop for React's reconciliation algorithm.\",\n suggestion: \"Add a unique key prop to each item. Use a stable ID, not array index.\",\n },\n {\n pattern: /ResizeObserver loop/i,\n title: \"ResizeObserver Loop\",\n explanation:\n \"A ResizeObserver callback caused another resize, creating an infinite loop. This is usually harmless but noisy.\",\n suggestion: \"This is often safe to ignore. If it causes issues, debounce the resize handler.\",\n },\n\n // === Authentication / Authorization ===\n {\n pattern: /jwt (expired|malformed|invalid)/i,\n title: \"JWT Error\",\n explanation:\n \"The JSON Web Token is invalid — it may be expired, malformed, or signed with the wrong key.\",\n suggestion: \"Check token expiration, refresh the token, or verify the signing key matches.\",\n },\n {\n pattern: /unauthorized|401/i,\n title: \"Unauthorized\",\n explanation: \"The request lacks valid authentication credentials.\",\n suggestion: \"Ensure the auth token is present and valid. Check for expired sessions.\",\n },\n {\n pattern: /forbidden|403/i,\n title: \"Forbidden\",\n explanation:\n \"The server understood the request but refuses to authorize it. The user doesn't have permission.\",\n suggestion: \"Check user permissions and roles. Verify the user has access to this resource.\",\n },\n\n // === CORS ===\n {\n pattern: /CORS|Access-Control-Allow-Origin|cross-origin/i,\n title: \"CORS Error\",\n explanation:\n \"The browser blocked a request to a different origin because the server didn't include the right CORS headers.\",\n suggestion:\n \"Configure the server to send Access-Control-Allow-Origin headers. For development, use a proxy or cors middleware.\",\n },\n\n // === Memory ===\n {\n pattern: /heap out of memory|ENOMEM|JavaScript heap/i,\n title: \"Out of Memory\",\n explanation:\n \"The process ran out of available memory. This could be a memory leak or processing too much data at once.\",\n suggestion:\n \"Increase memory limit with --max-old-space-size, check for memory leaks, or process data in chunks.\",\n },\n {\n pattern: /memory usage.*threshold|high memory/i,\n title: \"High Memory Usage\",\n explanation: \"The application's memory usage has exceeded the warning threshold.\",\n suggestion:\n \"Monitor for memory leaks. Consider restarting the process periodically or increasing available memory.\",\n },\n\n // === File System ===\n {\n pattern: /ENOENT|no such file or directory/i,\n title: \"File Not Found\",\n explanation: \"Your code tried to access a file or directory that doesn't exist.\",\n suggestion: \"Check the file path for typos. Ensure the file exists before accessing it.\",\n },\n {\n pattern: /EACCES|permission denied/i,\n title: \"Permission Denied\",\n explanation: \"The process doesn't have permission to access the file or resource.\",\n suggestion: \"Check file permissions. Run with appropriate user/group or fix file ownership.\",\n },\n {\n pattern: /EMFILE|too many open files/i,\n title: \"Too Many Open Files\",\n explanation:\n \"The process has opened more files than the OS allows. This often indicates a file descriptor leak.\",\n suggestion: \"Close files after use. Increase the ulimit, or check for leaked file descriptors.\",\n },\n\n // === Timeout ===\n {\n pattern: /timeout|timed out|ESOCKETTIMEDOUT/i,\n title: \"Operation Timed Out\",\n explanation:\n \"An operation took too long and was cancelled. The target service might be slow or overloaded.\",\n suggestion:\n \"Increase the timeout value, add retry logic, or investigate why the operation is slow.\",\n },\n\n // === Encoding / Parsing ===\n {\n pattern: /URIError|URI malformed/i,\n title: \"Malformed URI\",\n explanation: \"A URL encoding/decoding operation received an invalid URI.\",\n suggestion:\n \"Check the input for invalid characters. Use encodeURIComponent/decodeURIComponent correctly.\",\n },\n {\n pattern: /RangeError.*Invalid array length/i,\n title: \"Invalid Array Length\",\n explanation: \"An array was created with an invalid length (negative or too large).\",\n suggestion: \"Check the value being used as the array length.\",\n },\n\n // === Catch-all ===\n {\n pattern: /TypeError/i,\n title: \"Type Error\",\n explanation:\n \"A value is not the type that was expected. This often means using the wrong method on the wrong data type.\",\n suggestion:\n \"Check what type the variable actually is (using typeof or console.log) and handle it appropriately.\",\n },\n {\n pattern: /ReferenceError/i,\n title: \"Reference Error\",\n explanation: \"Your code references something that doesn't exist in the current scope.\",\n suggestion: \"Check for typos, missing imports, or variables used outside their scope.\",\n },\n {\n pattern: /SyntaxError/i,\n title: \"Syntax Error\",\n explanation: \"The code has a syntax error that prevents it from being parsed.\",\n suggestion:\n \"Check for missing brackets, quotes, commas, or other syntax issues around the reported location.\",\n },\n];\n","import { ERROR_PATTERNS, type ErrorPattern } from \"./patterns.js\";\n\nexport interface ErrorExplanation {\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport function explainError(message: string): ErrorExplanation | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return {\n title: pattern.title,\n explanation: pattern.explanation,\n suggestion: pattern.suggestion,\n };\n }\n }\n return null;\n}\n\nexport function matchPattern(message: string): ErrorPattern | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return pattern;\n }\n }\n return null;\n}\n","import { DEFAULT_SERVER_URL } from \"@errpulse/core\";\nimport type { ErrPulseEvent } from \"@errpulse/core\";\n\nexport interface NodeSDKConfig {\n serverUrl: string;\n projectId?: string;\n enabled: boolean;\n sampleRate: number;\n beforeSend?: (event: ErrPulseEvent) => ErrPulseEvent | null;\n captureConsoleErrors: boolean;\n captureUncaughtExceptions: boolean;\n captureUnhandledRejections: boolean;\n monitorMemory: boolean;\n memoryThresholdMB: number;\n memoryCheckIntervalMs: number;\n}\n\nconst defaultConfig: NodeSDKConfig = {\n serverUrl: DEFAULT_SERVER_URL,\n enabled: true,\n sampleRate: 1.0,\n captureConsoleErrors: true,\n captureUncaughtExceptions: true,\n captureUnhandledRejections: true,\n monitorMemory: true,\n memoryThresholdMB: 512,\n memoryCheckIntervalMs: 30000,\n};\n\nlet currentConfig: NodeSDKConfig = { ...defaultConfig };\n\nexport function configure(partial: Partial<NodeSDKConfig>): NodeSDKConfig {\n currentConfig = { ...currentConfig, ...partial };\n return currentConfig;\n}\n\nexport function getConfig(): NodeSDKConfig {\n return currentConfig;\n}\n","import { EVENTS_ENDPOINT, BATCH_SIZE, BATCH_INTERVAL_MS, type ErrPulseEvent } from \"@errpulse/core\";\nimport { getConfig } from \"./config.js\";\n\nlet buffer: ErrPulseEvent[] = [];\nlet flushTimer: ReturnType<typeof setTimeout> | null = null;\nlet isFlushing = false;\n\nasync function sendBatch(events: ErrPulseEvent[]): Promise<void> {\n const config = getConfig();\n if (!config.enabled || events.length === 0) return;\n\n const url =\n events.length === 1\n ? `${config.serverUrl}${EVENTS_ENDPOINT}`\n : `${config.serverUrl}${EVENTS_ENDPOINT}/batch`;\n const body = events.length === 1 ? events[0] : events;\n\n try {\n const resp = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(5000),\n });\n\n if (!resp.ok) {\n console.warn(`[ErrPulse] Failed to send events: ${resp.status}`);\n }\n } catch {\n // Silently fail — SDK must never crash host app\n }\n}\n\nfunction scheduleFlush(): void {\n if (flushTimer) return;\n flushTimer = setTimeout(() => {\n flushTimer = null;\n flush();\n }, BATCH_INTERVAL_MS);\n}\n\nasync function flush(): Promise<void> {\n if (isFlushing || buffer.length === 0) return;\n isFlushing = true;\n\n const batch = buffer.splice(0);\n await sendBatch(batch);\n\n isFlushing = false;\n\n // If more events accumulated during flush, schedule another\n if (buffer.length > 0) {\n scheduleFlush();\n }\n}\n\nexport function enqueueEvent(event: ErrPulseEvent): void {\n const config = getConfig();\n if (!config.enabled) return;\n\n // Sample rate check\n if (config.sampleRate < 1 && Math.random() > config.sampleRate) return;\n\n // Inject projectId\n if (config.projectId && !event.projectId) {\n event.projectId = config.projectId;\n }\n\n // beforeSend hook\n if (config.beforeSend) {\n const result = config.beforeSend(event);\n if (!result) return;\n buffer.push(result);\n } else {\n buffer.push(event);\n }\n\n if (buffer.length >= BATCH_SIZE) {\n flush();\n } else {\n scheduleFlush();\n }\n}\n\nexport async function flushAll(): Promise<void> {\n if (flushTimer) {\n clearTimeout(flushTimer);\n flushTimer = null;\n }\n await flush();\n}\n\n// Send a request log entry\nexport async function sendRequest(entry: {\n method: string;\n url: string;\n statusCode?: number;\n duration?: number;\n timestamp: string;\n correlationId?: string;\n errorEventId?: string;\n headers?: Record<string, string>;\n responseHeaders?: Record<string, string>;\n requestBody?: string;\n responseBody?: string;\n source?: string;\n projectId?: string;\n}): Promise<void> {\n const config = getConfig();\n if (!config.enabled) return;\n\n const payload = {\n ...entry,\n projectId: entry.projectId ?? config.projectId,\n };\n\n try {\n await fetch(`${config.serverUrl}${EVENTS_ENDPOINT}/request`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(5000),\n });\n } catch {\n // Silently fail\n }\n}\n","import type { StackFrame } from \"@errpulse/core\";\n\nconst NODE_STACK_RE = /^\\s*at\\s+(?:(.+?)\\s+\\()?(.+?):(\\d+):(\\d+)\\)?$/;\n\nexport function parseStack(stack: string): StackFrame[] {\n const frames: StackFrame[] = [];\n\n for (const line of stack.split(\"\\n\")) {\n const match = NODE_STACK_RE.exec(line);\n if (!match) continue;\n\n const [, fn, filename, lineno, colno] = match;\n\n const isNodeInternal =\n filename.startsWith(\"node:\") ||\n filename.includes(\"node_modules\") ||\n !filename.startsWith(\"/\");\n\n frames.push({\n function: fn || \"<anonymous>\",\n filename,\n lineno: Number(lineno),\n colno: Number(colno),\n inApp: !isNodeInternal,\n });\n }\n\n return frames;\n}\n","import type { EnvironmentInfo } from \"@errpulse/core\";\nimport os from \"os\";\n\nexport function getEnvironment(): EnvironmentInfo {\n const mem = process.memoryUsage();\n return {\n runtime: \"node\",\n runtimeVersion: process.version,\n nodeVersion: process.version,\n os: `${os.type()} ${os.release()}`,\n arch: os.arch(),\n memoryUsage: {\n heapUsed: mem.heapUsed,\n heapTotal: mem.heapTotal,\n rss: mem.rss,\n },\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, flushAll } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUncaughtExceptionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = async (error: Error) => {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UncaughtException,\n message: error.message || String(error),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Fatal,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n await flushAll();\n };\n\n process.on(\"uncaughtException\", handler);\n\n return () => {\n process.removeListener(\"uncaughtException\", handler);\n installed = false;\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUnhandledRejectionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = (reason: unknown) => {\n const error = reason instanceof Error ? reason : new Error(String(reason));\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UnhandledRejection,\n message: error.message || String(reason),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n };\n\n process.on(\"unhandledRejection\", handler);\n\n return () => {\n process.removeListener(\"unhandledRejection\", handler);\n installed = false;\n };\n}\n","import { AsyncLocalStorage } from \"async_hooks\";\nimport { CORRELATION_HEADER, generateCorrelationId } from \"@errpulse/core\";\n\nconst correlationStore = new AsyncLocalStorage<string>();\n\nexport function getCorrelationId(): string | undefined {\n return correlationStore.getStore();\n}\n\nexport function runWithCorrelation<T>(correlationId: string, fn: () => T): T {\n return correlationStore.run(correlationId, fn);\n}\n\nexport function extractOrCreateCorrelationId(\n headers: Record<string, string | string[] | undefined>\n): string {\n const existing = headers[CORRELATION_HEADER];\n if (typeof existing === \"string\" && existing) {\n return existing;\n }\n return generateCorrelationId();\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getCorrelationId } from \"../helpers/correlation.js\";\n\nlet originalConsoleError: typeof console.error | null = null;\n\nexport function installConsoleErrorInterceptor(): () => void {\n if (originalConsoleError) return () => {};\n\n originalConsoleError = console.error;\n\n console.error = (...args: unknown[]) => {\n // Always call original\n originalConsoleError!.apply(console, args);\n\n try {\n const message = args.map((a) => (typeof a === \"string\" ? a : JSON.stringify(a))).join(\" \");\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.ConsoleError,\n message,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash the host app\n }\n };\n\n return () => {\n if (originalConsoleError) {\n console.error = originalConsoleError;\n originalConsoleError = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getConfig } from \"../config.js\";\n\nlet intervalId: ReturnType<typeof setInterval> | null = null;\n\nexport function installMemoryMonitor(): () => void {\n if (intervalId) return () => {};\n\n const config = getConfig();\n\n intervalId = setInterval(() => {\n try {\n const mem = process.memoryUsage();\n const heapUsedMB = mem.heapUsed / (1024 * 1024);\n\n if (heapUsedMB > config.memoryThresholdMB) {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.MemoryWarning,\n message: `High memory usage: ${Math.round(heapUsedMB)}MB heap used (threshold: ${config.memoryThresholdMB}MB)`,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n extra: {\n heapUsedMB: Math.round(heapUsedMB),\n heapTotalMB: Math.round(mem.heapTotal / (1024 * 1024)),\n rssMB: Math.round(mem.rss / (1024 * 1024)),\n threshold: config.memoryThresholdMB,\n },\n };\n\n enqueueEvent(event);\n }\n } catch {\n // Never crash host app\n }\n }, config.memoryCheckIntervalMs);\n\n return () => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n sanitizeHeaders,\n sanitizeObject,\n CORRELATION_HEADER,\n type ErrPulseEvent,\n type RequestContext,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { extractOrCreateCorrelationId, runWithCorrelation } from \"../helpers/correlation.js\";\n\ntype Request = {\n method: string;\n url: string;\n originalUrl?: string;\n path?: string;\n headers: Record<string, string | string[] | undefined>;\n query?: Record<string, string>;\n body?: unknown;\n ip?: string;\n};\n\ntype Response = {\n statusCode: number;\n on(event: string, listener: () => void): void;\n getHeaders(): Record<string, string | string[] | number | undefined>;\n write: (...args: unknown[]) => boolean;\n end: (...args: unknown[]) => void;\n};\n\ntype NextFunction = (err?: unknown) => void;\n\n// Max size for request body capture (16 KB) to avoid performance issues\nconst MAX_BODY_SIZE = 16 * 1024;\n\nfunction flattenHeaders(\n headers: Record<string, string | string[] | number | undefined>\n): Record<string, string> {\n const flat: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (value === undefined) continue;\n flat[key] = Array.isArray(value) ? value.join(\", \") : String(value);\n }\n return flat;\n}\n\nfunction captureBody(body: unknown): string | undefined {\n if (body === undefined || body === null) return undefined;\n try {\n const str = typeof body === \"string\" ? body : JSON.stringify(sanitizeObject(body));\n // Truncate if too large\n if (str.length > MAX_BODY_SIZE) {\n return str.slice(0, MAX_BODY_SIZE) + \"...[truncated]\";\n }\n return str;\n } catch {\n return undefined;\n }\n}\n\nexport function expressRequestHandler() {\n return (req: Request, res: Response, next: NextFunction): void => {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n const startTime = Date.now();\n\n // Capture request headers and body early (before body may be consumed)\n const reqHeaders = sanitizeHeaders(\n flattenHeaders(req.headers as Record<string, string | string[] | number | undefined>)\n );\n const reqBody = captureBody(req.body);\n\n // Intercept response body by patching write/end (size-limited)\n const resChunks: Buffer[] = [];\n let resBodySize = 0;\n let resBodyOverflow = false;\n const origWrite = res.write;\n const origEnd = res.end;\n\n res.write = (chunk: unknown, ...args: unknown[]): boolean => {\n if (!resBodyOverflow && chunk) {\n const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));\n resBodySize += buf.length;\n if (resBodySize <= MAX_BODY_SIZE) {\n resChunks.push(buf);\n } else {\n resBodyOverflow = true;\n }\n }\n return (origWrite as Function).apply(res, [chunk, ...args]) as boolean;\n };\n\n res.end = (chunk: unknown, ...args: unknown[]): void => {\n if (!resBodyOverflow && chunk && typeof chunk !== \"function\") {\n const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));\n resBodySize += buf.length;\n if (resBodySize <= MAX_BODY_SIZE) {\n resChunks.push(buf);\n } else {\n resBodyOverflow = true;\n }\n }\n (origEnd as Function).apply(res, [chunk, ...args]);\n };\n\n // Track response completion to log request\n res.on(\"finish\", () => {\n try {\n const duration = Date.now() - startTime;\n\n // Capture response headers\n let resHeaders: Record<string, string> | undefined;\n try {\n resHeaders = flattenHeaders(res.getHeaders());\n } catch {\n // getHeaders may not exist in all environments\n }\n\n // Build response body string\n let resBody: string | undefined;\n if (resChunks.length > 0) {\n resBody = Buffer.concat(resChunks).toString(\"utf-8\");\n if (resBodyOverflow) {\n resBody += \"...[truncated]\";\n }\n }\n\n sendRequest({\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n headers: reqHeaders,\n responseHeaders: resHeaders,\n requestBody: reqBody,\n responseBody: resBody,\n source: \"backend\",\n });\n } catch {\n // Never crash host app\n }\n });\n\n // Run the rest of the middleware chain with correlation context\n runWithCorrelation(correlationId, () => next());\n };\n}\n\nexport function expressErrorHandler() {\n return (err: Error, req: Request, res: Response, next: NextFunction): void => {\n try {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n\n const requestContext: RequestContext = {\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode >= 400 ? res.statusCode : 500,\n headers: sanitizeHeaders(\n Object.fromEntries(\n Object.entries(req.headers).map(([k, v]) => [\n k,\n Array.isArray(v) ? v.join(\", \") : v || \"\",\n ])\n )\n ),\n query: req.query as Record<string, string>,\n ip: req.ip,\n userAgent: req.headers[\"user-agent\"] as string,\n };\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: requestContext,\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash host app\n }\n\n next(err);\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n CORRELATION_HEADER,\n generateCorrelationId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\ntype NextRequest = {\n method: string;\n url: string;\n headers: { get(name: string): string | null };\n nextUrl?: { pathname: string };\n};\n\ntype NextResponse = {\n status: number;\n};\n\n/**\n * Wraps a Next.js API route handler to capture errors and log requests.\n *\n * Usage:\n * import { withErrPulse } from '@errpulse/node'\n * export const GET = withErrPulse(async (req) => { ... })\n */\nexport function withErrPulse<T extends (...args: unknown[]) => Promise<unknown>>(handler: T): T {\n return (async (...args: unknown[]) => {\n const req = args[0] as NextRequest | undefined;\n const method = req?.method ?? \"UNKNOWN\";\n const url = req?.nextUrl?.pathname ?? req?.url ?? \"/\";\n const correlationId = req?.headers?.get(CORRELATION_HEADER) ?? generateCorrelationId();\n const startTime = Date.now();\n\n try {\n const result = await handler(...args);\n const duration = Date.now() - startTime;\n\n // Log the request\n const statusCode = (result as NextResponse)?.status ?? 200;\n sendRequest({\n method,\n url,\n statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n return result;\n } catch (error) {\n const duration = Date.now() - startTime;\n const err = error instanceof Error ? error : new Error(String(error));\n\n // Log the failed request\n sendRequest({\n method,\n url,\n statusCode: 500,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n // Capture the error\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: {\n method,\n url,\n statusCode: 500,\n duration,\n },\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n throw error;\n }\n }) as T;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAU,gBAAgB;AAEhC,QAAM,QAAuB;AAAA,IAC3B;AAAA,IACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,IAClC,MAAM,UAAU;AAAA,IAChB,SAAS,IAAI,WAAW,OAAO,GAAG;AAAA,IAClC,OAAO,IAAI;AAAA,IACX,aAAa,IAAI,QAAQ,WAAW,IAAI,KAAK,IAAI;AAAA,IACjD,QAAQ,YAAY;AAAA,IACpB,UAAU,SAAS;AAAA,IACnB,aAAa,eAAe;AAAA,IAC5B,eAAe,iBAAiB;AAAA,IAChC,WAAW,UAAU,EAAE;AAAA,IACvB;AAAA,EACF;AAEA,eAAa,KAAK;AAClB,SAAO;AACT;AAEO,SAAS,eACd,SACA,WAAyC,QACzC,OACQ;AACR,QAAM,UAAU,gBAAgB;AAEhC,QAAM,QAAuB;AAAA,IAC3B;AAAA,IACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,IAClC,MAAM,UAAU;AAAA,IAChB;AAAA,IACA,QAAQ,YAAY;AAAA,IACpB;AAAA,IACA,aAAa,eAAe;AAAA,IAC5B,eAAe,iBAAiB;AAAA,IAChC,WAAW,UAAU,EAAE;AAAA,IACvB;AAAA,EACF;AAEA,eAAa,KAAK;AAClB,SAAO;AACT;AAEO,SAAS,QAAc;AAC5B,aAAW,WAAW,UAAU;AAC9B,YAAQ;AAAA,EACV;AACA,WAAS,SAAS;AAClB,WAAS;AACX;AAGA,KAAK;","names":["ErrorSource","Severity","ErrorType","os","installed"]} |
+3
-0
@@ -32,2 +32,5 @@ import { ErrPulseEvent } from '@errpulse/core'; | ||
| on(event: string, listener: () => void): void; | ||
| getHeaders(): Record<string, string | string[] | number | undefined>; | ||
| write: (...args: unknown[]) => boolean; | ||
| end: (...args: unknown[]) => void; | ||
| }; | ||
@@ -34,0 +37,0 @@ type NextFunction = (err?: unknown) => void; |
+3
-0
@@ -32,2 +32,5 @@ import { ErrPulseEvent } from '@errpulse/core'; | ||
| on(event: string, listener: () => void): void; | ||
| getHeaders(): Record<string, string | string[] | number | undefined>; | ||
| write: (...args: unknown[]) => boolean; | ||
| end: (...args: unknown[]) => void; | ||
| }; | ||
@@ -34,0 +37,0 @@ type NextFunction = (err?: unknown) => void; |
+107
-0
@@ -40,2 +40,21 @@ // ../core/dist/index.js | ||
| ]; | ||
| var SENSITIVE_FIELDS = [ | ||
| "password", | ||
| "passwd", | ||
| "secret", | ||
| "token", | ||
| "apiKey", | ||
| "api_key", | ||
| "accessToken", | ||
| "access_token", | ||
| "refreshToken", | ||
| "refresh_token", | ||
| "creditCard", | ||
| "credit_card", | ||
| "ssn", | ||
| "cardNumber", | ||
| "card_number", | ||
| "cvv", | ||
| "cvc" | ||
| ]; | ||
| var REDACTED = "[Redacted]"; | ||
@@ -53,2 +72,20 @@ function sanitizeHeaders(headers) { | ||
| } | ||
| function sanitizeObject(obj) { | ||
| if (obj === null || obj === void 0) return obj; | ||
| if (typeof obj !== "object") return obj; | ||
| if (Array.isArray(obj)) { | ||
| return obj.map(sanitizeObject); | ||
| } | ||
| const sanitized = {}; | ||
| for (const [key, value] of Object.entries(obj)) { | ||
| if (SENSITIVE_FIELDS.some((f) => key.toLowerCase().includes(f.toLowerCase()))) { | ||
| sanitized[key] = REDACTED; | ||
| } else if (typeof value === "object" && value !== null) { | ||
| sanitized[key] = sanitizeObject(value); | ||
| } else { | ||
| sanitized[key] = value; | ||
| } | ||
| } | ||
| return sanitized; | ||
| } | ||
| function generateEventId() { | ||
@@ -349,2 +386,23 @@ return randomBytes(16).toString("hex"); | ||
| // src/integrations/express.ts | ||
| var MAX_BODY_SIZE = 16 * 1024; | ||
| function flattenHeaders(headers) { | ||
| const flat = {}; | ||
| for (const [key, value] of Object.entries(headers)) { | ||
| if (value === void 0) continue; | ||
| flat[key] = Array.isArray(value) ? value.join(", ") : String(value); | ||
| } | ||
| return flat; | ||
| } | ||
| function captureBody(body) { | ||
| if (body === void 0 || body === null) return void 0; | ||
| try { | ||
| const str = typeof body === "string" ? body : JSON.stringify(sanitizeObject(body)); | ||
| if (str.length > MAX_BODY_SIZE) { | ||
| return str.slice(0, MAX_BODY_SIZE) + "...[truncated]"; | ||
| } | ||
| return str; | ||
| } catch { | ||
| return void 0; | ||
| } | ||
| } | ||
| function expressRequestHandler() { | ||
@@ -356,5 +414,50 @@ return (req, res, next) => { | ||
| const startTime = Date.now(); | ||
| const reqHeaders = sanitizeHeaders( | ||
| flattenHeaders(req.headers) | ||
| ); | ||
| const reqBody = captureBody(req.body); | ||
| const resChunks = []; | ||
| let resBodySize = 0; | ||
| let resBodyOverflow = false; | ||
| const origWrite = res.write; | ||
| const origEnd = res.end; | ||
| res.write = (chunk, ...args) => { | ||
| if (!resBodyOverflow && chunk) { | ||
| const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)); | ||
| resBodySize += buf.length; | ||
| if (resBodySize <= MAX_BODY_SIZE) { | ||
| resChunks.push(buf); | ||
| } else { | ||
| resBodyOverflow = true; | ||
| } | ||
| } | ||
| return origWrite.apply(res, [chunk, ...args]); | ||
| }; | ||
| res.end = (chunk, ...args) => { | ||
| if (!resBodyOverflow && chunk && typeof chunk !== "function") { | ||
| const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)); | ||
| resBodySize += buf.length; | ||
| if (resBodySize <= MAX_BODY_SIZE) { | ||
| resChunks.push(buf); | ||
| } else { | ||
| resBodyOverflow = true; | ||
| } | ||
| } | ||
| origEnd.apply(res, [chunk, ...args]); | ||
| }; | ||
| res.on("finish", () => { | ||
| try { | ||
| const duration = Date.now() - startTime; | ||
| let resHeaders; | ||
| try { | ||
| resHeaders = flattenHeaders(res.getHeaders()); | ||
| } catch { | ||
| } | ||
| let resBody; | ||
| if (resChunks.length > 0) { | ||
| resBody = Buffer.concat(resChunks).toString("utf-8"); | ||
| if (resBodyOverflow) { | ||
| resBody += "...[truncated]"; | ||
| } | ||
| } | ||
| sendRequest({ | ||
@@ -367,2 +470,6 @@ method: req.method, | ||
| correlationId, | ||
| headers: reqHeaders, | ||
| responseHeaders: resHeaders, | ||
| requestBody: reqBody, | ||
| responseBody: resBody, | ||
| source: "backend" | ||
@@ -369,0 +476,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../../core/src/types/enums.ts","../../core/src/utils/fingerprint.ts","../../core/src/constants.ts","../../core/src/utils/normalize.ts","../../core/src/utils/sanitize.ts","../../core/src/utils/uuid.ts","../../core/src/explanations/patterns.ts","../../core/src/explanations/matcher.ts","../src/config.ts","../src/client.ts","../src/helpers/stack-parser.ts","../src/helpers/environment.ts","../src/instruments/uncaught-exception.ts","../src/instruments/unhandled-rejection.ts","../src/helpers/correlation.ts","../src/instruments/console-error.ts","../src/instruments/memory-monitor.ts","../src/integrations/express.ts","../src/integrations/nextjs.ts","../src/index.ts"],"sourcesContent":["export enum ErrorSource {\n Backend = \"backend\",\n Frontend = \"frontend\",\n}\n\nexport enum Severity {\n Fatal = \"fatal\",\n Error = \"error\",\n Warning = \"warning\",\n Info = \"info\",\n}\n\nexport enum ErrorType {\n UncaughtException = \"uncaught_exception\",\n UnhandledRejection = \"unhandled_rejection\",\n HttpError = \"http_error\",\n ConsoleError = \"console_error\",\n ReactError = \"react_error\",\n ResourceError = \"resource_error\",\n NetworkError = \"network_error\",\n MemoryWarning = \"memory_warning\",\n Manual = \"manual\",\n}\n\nexport enum ErrorStatus {\n Unresolved = \"unresolved\",\n Acknowledged = \"acknowledged\",\n Resolved = \"resolved\",\n Ignored = \"ignored\",\n}\n","import { createHash } from \"crypto\";\nimport type { ErrPulseEvent, StackFrame } from \"../types/error-event.js\";\nimport { normalizeMessage, getTopFrames } from \"./normalize.js\";\n\nfunction frameKey(frame: StackFrame): string {\n return `${frame.filename}:${frame.function}`;\n}\n\nexport function computeFingerprint(event: ErrPulseEvent): string {\n const parts: string[] = [event.type];\n\n parts.push(normalizeMessage(event.message));\n\n if (event.stackFrames && event.stackFrames.length > 0) {\n const topFrames = getTopFrames(event.stackFrames, 3);\n for (const frame of topFrames) {\n parts.push(frameKey(frame));\n }\n }\n\n const input = parts.join(\"\\n\");\n return createHash(\"sha256\").update(input).digest(\"hex\").slice(0, 32);\n}\n","export const DEFAULT_SERVER_PORT = 3800;\nexport const DEFAULT_DB_DIR = \".errpulse\";\nexport const DEFAULT_DB_FILENAME = \"errpulse.db\";\nexport const DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_SERVER_PORT}`;\nexport const EVENTS_ENDPOINT = \"/api/events\";\nexport const ERRORS_ENDPOINT = \"/api/errors\";\nexport const REQUESTS_ENDPOINT = \"/api/requests\";\nexport const HEALTH_ENDPOINT = \"/api/health\";\nexport const STATS_ENDPOINT = \"/api/stats\";\nexport const CORRELATION_HEADER = \"x-errpulse-correlation-id\";\nexport const PROJECT_HEADER = \"x-errpulse-project-id\";\nexport const MAX_MESSAGE_LENGTH = 2048;\nexport const MAX_STACK_FRAMES = 50;\nexport const BATCH_SIZE = 10;\nexport const BATCH_INTERVAL_MS = 100;\nexport const SENSITIVE_HEADERS = [\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"x-auth-token\",\n];\nexport const SENSITIVE_FIELDS = [\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"apiKey\",\n \"api_key\",\n \"accessToken\",\n \"access_token\",\n \"refreshToken\",\n \"refresh_token\",\n \"creditCard\",\n \"credit_card\",\n \"ssn\",\n \"cardNumber\",\n \"card_number\",\n \"cvv\",\n \"cvc\",\n];\n","import { MAX_MESSAGE_LENGTH, MAX_STACK_FRAMES } from \"../constants.js\";\nimport type { StackFrame } from \"../types/error-event.js\";\n\nexport function normalizeMessage(message: string): string {\n let normalized = message.trim();\n\n // Remove memory addresses (0x1a2b3c4d)\n normalized = normalized.replace(/0x[0-9a-fA-F]+/g, \"0x?\");\n\n // Remove specific line/column numbers from inline references\n normalized = normalized.replace(/:\\d+:\\d+/g, \":?:?\");\n\n // Remove UUIDs\n normalized = normalized.replace(\n /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,\n \"<uuid>\"\n );\n\n // Remove specific port numbers in URLs\n normalized = normalized.replace(/localhost:\\d+/g, \"localhost:?\");\n\n // Remove absolute file paths, keep filename\n normalized = normalized.replace(\n /(?:\\/[\\w.-]+)+\\/([\\w.-]+)/g,\n (_match, filename: string) => `<path>/${filename}`\n );\n\n // Truncate\n if (normalized.length > MAX_MESSAGE_LENGTH) {\n normalized = normalized.slice(0, MAX_MESSAGE_LENGTH) + \"...\";\n }\n\n return normalized;\n}\n\nexport function normalizeStackFrames(frames: StackFrame[]): StackFrame[] {\n return frames.slice(0, MAX_STACK_FRAMES);\n}\n\nexport function getInAppFrames(frames: StackFrame[]): StackFrame[] {\n return frames.filter((f) => f.inApp);\n}\n\nexport function getTopFrames(frames: StackFrame[], count: number): StackFrame[] {\n const inApp = getInAppFrames(frames);\n return inApp.length > 0 ? inApp.slice(0, count) : frames.slice(0, count);\n}\n","import { SENSITIVE_HEADERS, SENSITIVE_FIELDS } from \"../constants.js\";\n\nconst REDACTED = \"[Redacted]\";\n\nexport function sanitizeHeaders(headers: Record<string, string>): Record<string, string> {\n const sanitized: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (SENSITIVE_HEADERS.includes(key.toLowerCase())) {\n sanitized[key] = REDACTED;\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n\nexport function sanitizeObject(obj: unknown): unknown {\n if (obj === null || obj === undefined) return obj;\n if (typeof obj !== \"object\") return obj;\n\n if (Array.isArray(obj)) {\n return obj.map(sanitizeObject);\n }\n\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n if (SENSITIVE_FIELDS.some((f) => key.toLowerCase().includes(f.toLowerCase()))) {\n sanitized[key] = REDACTED;\n } else if (typeof value === \"object\" && value !== null) {\n sanitized[key] = sanitizeObject(value);\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n","import { randomBytes } from \"crypto\";\n\nexport function generateEventId(): string {\n return randomBytes(16).toString(\"hex\");\n}\n\nexport function generateCorrelationId(): string {\n return randomBytes(8).toString(\"hex\");\n}\n","export interface ErrorPattern {\n pattern: RegExp;\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport const ERROR_PATTERNS: ErrorPattern[] = [\n // === Type Errors ===\n {\n pattern: /Cannot read propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Reference Access\",\n explanation:\n \"Your code tried to access a property on something that is undefined or null. This usually means a variable wasn't initialized, an API returned unexpected data, or an object was accessed before it was ready.\",\n suggestion:\n \"Add optional chaining (?.) or a null check before accessing the property. For example: obj?.property instead of obj.property.\",\n },\n {\n pattern: /Cannot set propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Assignment\",\n explanation: \"Your code tried to set a property on something that is undefined or null.\",\n suggestion:\n \"Check that the object exists before assigning to it. Initialize the object first if needed.\",\n },\n {\n pattern: /(\\w+) is not a function/i,\n title: \"Not a Function\",\n explanation:\n \"Your code tried to call something as a function, but it's not one. This often happens when a method name is misspelled, an import is wrong, or a callback wasn't passed correctly.\",\n suggestion:\n \"Check the spelling, verify the import, and make sure the value is actually a function before calling it.\",\n },\n {\n pattern: /(\\w+) is not defined/i,\n title: \"Undefined Variable\",\n explanation:\n \"Your code references a variable that doesn't exist in the current scope. This could be a typo, a missing import, or a scoping issue.\",\n suggestion:\n \"Check for typos in the variable name and ensure it's imported or declared before use.\",\n },\n {\n pattern: /Cannot access '(\\w+)' before initialization/i,\n title: \"Temporal Dead Zone\",\n explanation:\n \"A variable declared with let or const was used before its declaration was reached. JavaScript hoists the declaration but not the initialization.\",\n suggestion:\n \"Move the variable declaration before its first use, or restructure the code to avoid the circular dependency.\",\n },\n {\n pattern: /Assignment to constant variable/i,\n title: \"Constant Reassignment\",\n explanation: \"Your code tried to reassign a variable declared with const.\",\n suggestion: \"Use let instead of const if you need to reassign the variable.\",\n },\n {\n pattern: /Maximum call stack size exceeded/i,\n title: \"Stack Overflow\",\n explanation:\n \"A function called itself recursively without a proper exit condition, causing an infinite loop of calls until the stack ran out of space.\",\n suggestion:\n \"Add or fix the base case in your recursive function. Check for unintended circular calls between functions.\",\n },\n\n // === Syntax / Module Errors ===\n {\n pattern: /Unexpected token/i,\n title: \"Syntax Error\",\n explanation:\n \"The JavaScript parser found a character it didn't expect. This usually means a missing bracket, comma, or quote somewhere.\",\n suggestion:\n \"Check the file around the reported line for missing or extra brackets, commas, semicolons, or quotes.\",\n },\n {\n pattern: /Cannot find module '(.+)'/i,\n title: \"Module Not Found\",\n explanation:\n \"Node.js couldn't find the module you tried to import. Either the package isn't installed, the file path is wrong, or the module name is misspelled.\",\n suggestion:\n \"Run npm install to ensure all dependencies are installed. Check the import path for typos.\",\n },\n {\n pattern: /SyntaxError: .* is not valid JSON/i,\n title: \"Invalid JSON\",\n explanation:\n \"Your code tried to parse a string as JSON, but the string isn't valid JSON. This often happens when an API returns HTML (like an error page) instead of JSON.\",\n suggestion:\n \"Log the raw response before parsing. Check that the API endpoint is correct and returning JSON.\",\n },\n\n // === Network & HTTP Errors ===\n {\n pattern: /ECONNREFUSED/i,\n title: \"Connection Refused\",\n explanation:\n \"Your app tried to connect to a server that isn't accepting connections. The target service is either not running, listening on a different port, or blocked by a firewall.\",\n suggestion: \"Make sure the target service is running and listening on the expected host:port.\",\n },\n {\n pattern: /ECONNRESET/i,\n title: \"Connection Reset\",\n explanation:\n \"The remote server abruptly closed the connection. This can happen due to server crashes, timeouts, or network issues.\",\n suggestion: \"Add retry logic with backoff. Check the remote server's logs for errors.\",\n },\n {\n pattern: /ETIMEDOUT/i,\n title: \"Connection Timed Out\",\n explanation:\n \"The connection to the remote server took too long and was abandoned. The server might be overloaded or unreachable.\",\n suggestion: \"Increase the timeout, check network connectivity, or add retry logic.\",\n },\n {\n pattern: /ENOTFOUND/i,\n title: \"DNS Lookup Failed\",\n explanation:\n \"The hostname couldn't be resolved to an IP address. The domain name is wrong or DNS is not working.\",\n suggestion: \"Check the hostname for typos. Verify DNS resolution is working.\",\n },\n {\n pattern: /EADDRINUSE/i,\n title: \"Port Already in Use\",\n explanation: \"Your app tried to listen on a port that's already taken by another process.\",\n suggestion: \"Use a different port, or find and stop the process using that port: lsof -i :PORT\",\n },\n {\n pattern: /fetch failed|Failed to fetch/i,\n title: \"Fetch Failed\",\n explanation:\n \"A network request failed completely. This usually means the server is unreachable, CORS blocked the request, or there's no internet connection.\",\n suggestion:\n \"Check that the URL is correct, the server is running, and CORS is configured if calling from a browser.\",\n },\n {\n pattern: /Network request failed/i,\n title: \"Network Error\",\n explanation:\n \"A network request could not complete. The server may be down, the URL may be wrong, or the network may be unavailable.\",\n suggestion: \"Verify the target URL and network connectivity.\",\n },\n {\n pattern: /status code 4\\d{2}/i,\n title: \"Client Error (4xx)\",\n explanation:\n \"The server rejected the request due to a client-side issue — bad request data, missing auth, or accessing a resource that doesn't exist.\",\n suggestion: \"Check the request URL, headers, authentication, and body for correctness.\",\n },\n {\n pattern: /status code 5\\d{2}/i,\n title: \"Server Error (5xx)\",\n explanation: \"The server encountered an internal error while processing the request.\",\n suggestion: \"Check the server logs for the root cause. This is a backend issue.\",\n },\n\n // === Database Errors ===\n {\n pattern: /ER_DUP_ENTRY|duplicate key|unique constraint/i,\n title: \"Duplicate Entry\",\n explanation:\n \"A database insert or update violated a unique constraint — you're trying to insert data that already exists.\",\n suggestion: \"Use upsert/ON CONFLICT, or check for existing records before inserting.\",\n },\n {\n pattern: /ER_NO_SUCH_TABLE|relation .* does not exist|no such table/i,\n title: \"Table Not Found\",\n explanation: \"The query references a database table that doesn't exist.\",\n suggestion: \"Run your database migrations. Check that the table name is spelled correctly.\",\n },\n {\n pattern: /ER_PARSE_ERROR|syntax error at or near/i,\n title: \"SQL Syntax Error\",\n explanation: \"Your SQL query has a syntax error.\",\n suggestion: \"Check the SQL query for typos, missing commas, or incorrect keywords.\",\n },\n {\n pattern: /SQLITE_BUSY/i,\n title: \"Database Busy\",\n explanation:\n \"SQLite couldn't acquire a lock because another connection is writing. This happens with concurrent writes.\",\n suggestion: \"Enable WAL mode, reduce write contention, or add retry logic.\",\n },\n {\n pattern: /connection.*refused.*database|Can't connect to/i,\n title: \"Database Connection Failed\",\n explanation:\n \"Your app couldn't connect to the database server. The database might not be running or the connection string is wrong.\",\n suggestion:\n \"Verify the database is running and the connection string (host, port, credentials) is correct.\",\n },\n\n // === React / Frontend Errors ===\n {\n pattern: /Minified React error #(\\d+)/i,\n title: \"React Production Error\",\n explanation:\n \"React threw an error in production mode. The error is minified — check the React error decoder for details.\",\n suggestion:\n \"Look up the error number at https://reactjs.org/docs/error-decoder.html for the full message.\",\n },\n {\n pattern: /Hydration failed|Text content does not match|did not match/i,\n title: \"Hydration Mismatch\",\n explanation:\n \"The HTML rendered on the server doesn't match what React tried to render on the client. This causes the page to re-render completely.\",\n suggestion:\n \"Ensure server and client render identical output. Avoid using Date.now(), Math.random(), or browser-only APIs during initial render.\",\n },\n {\n pattern: /Invalid hook call/i,\n title: \"Invalid React Hook Call\",\n explanation:\n \"A React hook was called outside of a function component, or you have multiple copies of React in your bundle.\",\n suggestion:\n \"Only call hooks at the top level of function components. Check for duplicate React versions with npm ls react.\",\n },\n {\n pattern: /Objects are not valid as a React child/i,\n title: \"Invalid React Child\",\n explanation: \"You tried to render a plain object as a React child, which isn't allowed.\",\n suggestion:\n \"Convert the object to a string (JSON.stringify) or render its properties individually.\",\n },\n {\n pattern: /Each child in a list should have a unique \"key\" prop/i,\n title: \"Missing React Key\",\n explanation:\n \"When rendering a list of elements, each item needs a unique key prop for React's reconciliation algorithm.\",\n suggestion: \"Add a unique key prop to each item. Use a stable ID, not array index.\",\n },\n {\n pattern: /ResizeObserver loop/i,\n title: \"ResizeObserver Loop\",\n explanation:\n \"A ResizeObserver callback caused another resize, creating an infinite loop. This is usually harmless but noisy.\",\n suggestion: \"This is often safe to ignore. If it causes issues, debounce the resize handler.\",\n },\n\n // === Authentication / Authorization ===\n {\n pattern: /jwt (expired|malformed|invalid)/i,\n title: \"JWT Error\",\n explanation:\n \"The JSON Web Token is invalid — it may be expired, malformed, or signed with the wrong key.\",\n suggestion: \"Check token expiration, refresh the token, or verify the signing key matches.\",\n },\n {\n pattern: /unauthorized|401/i,\n title: \"Unauthorized\",\n explanation: \"The request lacks valid authentication credentials.\",\n suggestion: \"Ensure the auth token is present and valid. Check for expired sessions.\",\n },\n {\n pattern: /forbidden|403/i,\n title: \"Forbidden\",\n explanation:\n \"The server understood the request but refuses to authorize it. The user doesn't have permission.\",\n suggestion: \"Check user permissions and roles. Verify the user has access to this resource.\",\n },\n\n // === CORS ===\n {\n pattern: /CORS|Access-Control-Allow-Origin|cross-origin/i,\n title: \"CORS Error\",\n explanation:\n \"The browser blocked a request to a different origin because the server didn't include the right CORS headers.\",\n suggestion:\n \"Configure the server to send Access-Control-Allow-Origin headers. For development, use a proxy or cors middleware.\",\n },\n\n // === Memory ===\n {\n pattern: /heap out of memory|ENOMEM|JavaScript heap/i,\n title: \"Out of Memory\",\n explanation:\n \"The process ran out of available memory. This could be a memory leak or processing too much data at once.\",\n suggestion:\n \"Increase memory limit with --max-old-space-size, check for memory leaks, or process data in chunks.\",\n },\n {\n pattern: /memory usage.*threshold|high memory/i,\n title: \"High Memory Usage\",\n explanation: \"The application's memory usage has exceeded the warning threshold.\",\n suggestion:\n \"Monitor for memory leaks. Consider restarting the process periodically or increasing available memory.\",\n },\n\n // === File System ===\n {\n pattern: /ENOENT|no such file or directory/i,\n title: \"File Not Found\",\n explanation: \"Your code tried to access a file or directory that doesn't exist.\",\n suggestion: \"Check the file path for typos. Ensure the file exists before accessing it.\",\n },\n {\n pattern: /EACCES|permission denied/i,\n title: \"Permission Denied\",\n explanation: \"The process doesn't have permission to access the file or resource.\",\n suggestion: \"Check file permissions. Run with appropriate user/group or fix file ownership.\",\n },\n {\n pattern: /EMFILE|too many open files/i,\n title: \"Too Many Open Files\",\n explanation:\n \"The process has opened more files than the OS allows. This often indicates a file descriptor leak.\",\n suggestion: \"Close files after use. Increase the ulimit, or check for leaked file descriptors.\",\n },\n\n // === Timeout ===\n {\n pattern: /timeout|timed out|ESOCKETTIMEDOUT/i,\n title: \"Operation Timed Out\",\n explanation:\n \"An operation took too long and was cancelled. The target service might be slow or overloaded.\",\n suggestion:\n \"Increase the timeout value, add retry logic, or investigate why the operation is slow.\",\n },\n\n // === Encoding / Parsing ===\n {\n pattern: /URIError|URI malformed/i,\n title: \"Malformed URI\",\n explanation: \"A URL encoding/decoding operation received an invalid URI.\",\n suggestion:\n \"Check the input for invalid characters. Use encodeURIComponent/decodeURIComponent correctly.\",\n },\n {\n pattern: /RangeError.*Invalid array length/i,\n title: \"Invalid Array Length\",\n explanation: \"An array was created with an invalid length (negative or too large).\",\n suggestion: \"Check the value being used as the array length.\",\n },\n\n // === Catch-all ===\n {\n pattern: /TypeError/i,\n title: \"Type Error\",\n explanation:\n \"A value is not the type that was expected. This often means using the wrong method on the wrong data type.\",\n suggestion:\n \"Check what type the variable actually is (using typeof or console.log) and handle it appropriately.\",\n },\n {\n pattern: /ReferenceError/i,\n title: \"Reference Error\",\n explanation: \"Your code references something that doesn't exist in the current scope.\",\n suggestion: \"Check for typos, missing imports, or variables used outside their scope.\",\n },\n {\n pattern: /SyntaxError/i,\n title: \"Syntax Error\",\n explanation: \"The code has a syntax error that prevents it from being parsed.\",\n suggestion:\n \"Check for missing brackets, quotes, commas, or other syntax issues around the reported location.\",\n },\n];\n","import { ERROR_PATTERNS, type ErrorPattern } from \"./patterns.js\";\n\nexport interface ErrorExplanation {\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport function explainError(message: string): ErrorExplanation | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return {\n title: pattern.title,\n explanation: pattern.explanation,\n suggestion: pattern.suggestion,\n };\n }\n }\n return null;\n}\n\nexport function matchPattern(message: string): ErrorPattern | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return pattern;\n }\n }\n return null;\n}\n","import { DEFAULT_SERVER_URL } from \"@errpulse/core\";\nimport type { ErrPulseEvent } from \"@errpulse/core\";\n\nexport interface NodeSDKConfig {\n serverUrl: string;\n projectId?: string;\n enabled: boolean;\n sampleRate: number;\n beforeSend?: (event: ErrPulseEvent) => ErrPulseEvent | null;\n captureConsoleErrors: boolean;\n captureUncaughtExceptions: boolean;\n captureUnhandledRejections: boolean;\n monitorMemory: boolean;\n memoryThresholdMB: number;\n memoryCheckIntervalMs: number;\n}\n\nconst defaultConfig: NodeSDKConfig = {\n serverUrl: DEFAULT_SERVER_URL,\n enabled: true,\n sampleRate: 1.0,\n captureConsoleErrors: true,\n captureUncaughtExceptions: true,\n captureUnhandledRejections: true,\n monitorMemory: true,\n memoryThresholdMB: 512,\n memoryCheckIntervalMs: 30000,\n};\n\nlet currentConfig: NodeSDKConfig = { ...defaultConfig };\n\nexport function configure(partial: Partial<NodeSDKConfig>): NodeSDKConfig {\n currentConfig = { ...currentConfig, ...partial };\n return currentConfig;\n}\n\nexport function getConfig(): NodeSDKConfig {\n return currentConfig;\n}\n","import { EVENTS_ENDPOINT, BATCH_SIZE, BATCH_INTERVAL_MS, type ErrPulseEvent } from \"@errpulse/core\";\nimport { getConfig } from \"./config.js\";\n\nlet buffer: ErrPulseEvent[] = [];\nlet flushTimer: ReturnType<typeof setTimeout> | null = null;\nlet isFlushing = false;\n\nasync function sendBatch(events: ErrPulseEvent[]): Promise<void> {\n const config = getConfig();\n if (!config.enabled || events.length === 0) return;\n\n const url =\n events.length === 1\n ? `${config.serverUrl}${EVENTS_ENDPOINT}`\n : `${config.serverUrl}${EVENTS_ENDPOINT}/batch`;\n const body = events.length === 1 ? events[0] : events;\n\n try {\n const resp = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(5000),\n });\n\n if (!resp.ok) {\n console.warn(`[ErrPulse] Failed to send events: ${resp.status}`);\n }\n } catch {\n // Silently fail — SDK must never crash host app\n }\n}\n\nfunction scheduleFlush(): void {\n if (flushTimer) return;\n flushTimer = setTimeout(() => {\n flushTimer = null;\n flush();\n }, BATCH_INTERVAL_MS);\n}\n\nasync function flush(): Promise<void> {\n if (isFlushing || buffer.length === 0) return;\n isFlushing = true;\n\n const batch = buffer.splice(0);\n await sendBatch(batch);\n\n isFlushing = false;\n\n // If more events accumulated during flush, schedule another\n if (buffer.length > 0) {\n scheduleFlush();\n }\n}\n\nexport function enqueueEvent(event: ErrPulseEvent): void {\n const config = getConfig();\n if (!config.enabled) return;\n\n // Sample rate check\n if (config.sampleRate < 1 && Math.random() > config.sampleRate) return;\n\n // Inject projectId\n if (config.projectId && !event.projectId) {\n event.projectId = config.projectId;\n }\n\n // beforeSend hook\n if (config.beforeSend) {\n const result = config.beforeSend(event);\n if (!result) return;\n buffer.push(result);\n } else {\n buffer.push(event);\n }\n\n if (buffer.length >= BATCH_SIZE) {\n flush();\n } else {\n scheduleFlush();\n }\n}\n\nexport async function flushAll(): Promise<void> {\n if (flushTimer) {\n clearTimeout(flushTimer);\n flushTimer = null;\n }\n await flush();\n}\n\n// Send a request log entry\nexport async function sendRequest(entry: {\n method: string;\n url: string;\n statusCode?: number;\n duration?: number;\n timestamp: string;\n correlationId?: string;\n errorEventId?: string;\n source?: string;\n projectId?: string;\n}): Promise<void> {\n const config = getConfig();\n if (!config.enabled) return;\n\n const payload = {\n ...entry,\n projectId: entry.projectId ?? config.projectId,\n };\n\n try {\n await fetch(`${config.serverUrl}${EVENTS_ENDPOINT}/request`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(5000),\n });\n } catch {\n // Silently fail\n }\n}\n","import type { StackFrame } from \"@errpulse/core\";\n\nconst NODE_STACK_RE = /^\\s*at\\s+(?:(.+?)\\s+\\()?(.+?):(\\d+):(\\d+)\\)?$/;\n\nexport function parseStack(stack: string): StackFrame[] {\n const frames: StackFrame[] = [];\n\n for (const line of stack.split(\"\\n\")) {\n const match = NODE_STACK_RE.exec(line);\n if (!match) continue;\n\n const [, fn, filename, lineno, colno] = match;\n\n const isNodeInternal =\n filename.startsWith(\"node:\") ||\n filename.includes(\"node_modules\") ||\n !filename.startsWith(\"/\");\n\n frames.push({\n function: fn || \"<anonymous>\",\n filename,\n lineno: Number(lineno),\n colno: Number(colno),\n inApp: !isNodeInternal,\n });\n }\n\n return frames;\n}\n","import type { EnvironmentInfo } from \"@errpulse/core\";\nimport os from \"os\";\n\nexport function getEnvironment(): EnvironmentInfo {\n const mem = process.memoryUsage();\n return {\n runtime: \"node\",\n runtimeVersion: process.version,\n nodeVersion: process.version,\n os: `${os.type()} ${os.release()}`,\n arch: os.arch(),\n memoryUsage: {\n heapUsed: mem.heapUsed,\n heapTotal: mem.heapTotal,\n rss: mem.rss,\n },\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, flushAll } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUncaughtExceptionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = async (error: Error) => {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UncaughtException,\n message: error.message || String(error),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Fatal,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n await flushAll();\n };\n\n process.on(\"uncaughtException\", handler);\n\n return () => {\n process.removeListener(\"uncaughtException\", handler);\n installed = false;\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUnhandledRejectionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = (reason: unknown) => {\n const error = reason instanceof Error ? reason : new Error(String(reason));\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UnhandledRejection,\n message: error.message || String(reason),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n };\n\n process.on(\"unhandledRejection\", handler);\n\n return () => {\n process.removeListener(\"unhandledRejection\", handler);\n installed = false;\n };\n}\n","import { AsyncLocalStorage } from \"async_hooks\";\nimport { CORRELATION_HEADER, generateCorrelationId } from \"@errpulse/core\";\n\nconst correlationStore = new AsyncLocalStorage<string>();\n\nexport function getCorrelationId(): string | undefined {\n return correlationStore.getStore();\n}\n\nexport function runWithCorrelation<T>(correlationId: string, fn: () => T): T {\n return correlationStore.run(correlationId, fn);\n}\n\nexport function extractOrCreateCorrelationId(\n headers: Record<string, string | string[] | undefined>\n): string {\n const existing = headers[CORRELATION_HEADER];\n if (typeof existing === \"string\" && existing) {\n return existing;\n }\n return generateCorrelationId();\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getCorrelationId } from \"../helpers/correlation.js\";\n\nlet originalConsoleError: typeof console.error | null = null;\n\nexport function installConsoleErrorInterceptor(): () => void {\n if (originalConsoleError) return () => {};\n\n originalConsoleError = console.error;\n\n console.error = (...args: unknown[]) => {\n // Always call original\n originalConsoleError!.apply(console, args);\n\n try {\n const message = args.map((a) => (typeof a === \"string\" ? a : JSON.stringify(a))).join(\" \");\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.ConsoleError,\n message,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash the host app\n }\n };\n\n return () => {\n if (originalConsoleError) {\n console.error = originalConsoleError;\n originalConsoleError = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getConfig } from \"../config.js\";\n\nlet intervalId: ReturnType<typeof setInterval> | null = null;\n\nexport function installMemoryMonitor(): () => void {\n if (intervalId) return () => {};\n\n const config = getConfig();\n\n intervalId = setInterval(() => {\n try {\n const mem = process.memoryUsage();\n const heapUsedMB = mem.heapUsed / (1024 * 1024);\n\n if (heapUsedMB > config.memoryThresholdMB) {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.MemoryWarning,\n message: `High memory usage: ${Math.round(heapUsedMB)}MB heap used (threshold: ${config.memoryThresholdMB}MB)`,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n extra: {\n heapUsedMB: Math.round(heapUsedMB),\n heapTotalMB: Math.round(mem.heapTotal / (1024 * 1024)),\n rssMB: Math.round(mem.rss / (1024 * 1024)),\n threshold: config.memoryThresholdMB,\n },\n };\n\n enqueueEvent(event);\n }\n } catch {\n // Never crash host app\n }\n }, config.memoryCheckIntervalMs);\n\n return () => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n sanitizeHeaders,\n CORRELATION_HEADER,\n type ErrPulseEvent,\n type RequestContext,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { extractOrCreateCorrelationId, runWithCorrelation } from \"../helpers/correlation.js\";\n\ntype Request = {\n method: string;\n url: string;\n originalUrl?: string;\n path?: string;\n headers: Record<string, string | string[] | undefined>;\n query?: Record<string, string>;\n body?: unknown;\n ip?: string;\n};\n\ntype Response = {\n statusCode: number;\n on(event: string, listener: () => void): void;\n};\n\ntype NextFunction = (err?: unknown) => void;\n\nexport function expressRequestHandler() {\n return (req: Request, res: Response, next: NextFunction): void => {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n const startTime = Date.now();\n\n // Track response completion to log request\n res.on(\"finish\", () => {\n try {\n const duration = Date.now() - startTime;\n sendRequest({\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n } catch {\n // Never crash host app\n }\n });\n\n // Run the rest of the middleware chain with correlation context\n runWithCorrelation(correlationId, () => next());\n };\n}\n\nexport function expressErrorHandler() {\n return (err: Error, req: Request, res: Response, next: NextFunction): void => {\n try {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n\n const requestContext: RequestContext = {\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode >= 400 ? res.statusCode : 500,\n headers: sanitizeHeaders(\n Object.fromEntries(\n Object.entries(req.headers).map(([k, v]) => [\n k,\n Array.isArray(v) ? v.join(\", \") : v || \"\",\n ])\n )\n ),\n query: req.query as Record<string, string>,\n ip: req.ip,\n userAgent: req.headers[\"user-agent\"] as string,\n };\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: requestContext,\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash host app\n }\n\n next(err);\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n CORRELATION_HEADER,\n generateCorrelationId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\ntype NextRequest = {\n method: string;\n url: string;\n headers: { get(name: string): string | null };\n nextUrl?: { pathname: string };\n};\n\ntype NextResponse = {\n status: number;\n};\n\n/**\n * Wraps a Next.js API route handler to capture errors and log requests.\n *\n * Usage:\n * import { withErrPulse } from '@errpulse/node'\n * export const GET = withErrPulse(async (req) => { ... })\n */\nexport function withErrPulse<T extends (...args: unknown[]) => Promise<unknown>>(handler: T): T {\n return (async (...args: unknown[]) => {\n const req = args[0] as NextRequest | undefined;\n const method = req?.method ?? \"UNKNOWN\";\n const url = req?.nextUrl?.pathname ?? req?.url ?? \"/\";\n const correlationId = req?.headers?.get(CORRELATION_HEADER) ?? generateCorrelationId();\n const startTime = Date.now();\n\n try {\n const result = await handler(...args);\n const duration = Date.now() - startTime;\n\n // Log the request\n const statusCode = (result as NextResponse)?.status ?? 200;\n sendRequest({\n method,\n url,\n statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n return result;\n } catch (error) {\n const duration = Date.now() - startTime;\n const err = error instanceof Error ? error : new Error(String(error));\n\n // Log the failed request\n sendRequest({\n method,\n url,\n statusCode: 500,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n // Capture the error\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: {\n method,\n url,\n statusCode: 500,\n duration,\n },\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n throw error;\n }\n }) as T;\n}\n","import type { ErrPulseEvent } from \"@errpulse/core\";\nimport { ErrorType, ErrorSource, Severity, generateEventId } from \"@errpulse/core\";\nimport { configure, getConfig, type NodeSDKConfig } from \"./config.js\";\nimport { enqueueEvent, flushAll } from \"./client.js\";\nimport { installUncaughtExceptionHandler } from \"./instruments/uncaught-exception.js\";\nimport { installUnhandledRejectionHandler } from \"./instruments/unhandled-rejection.js\";\nimport { installConsoleErrorInterceptor } from \"./instruments/console-error.js\";\nimport { installMemoryMonitor } from \"./instruments/memory-monitor.js\";\nimport { parseStack } from \"./helpers/stack-parser.js\";\nimport { getEnvironment } from \"./helpers/environment.js\";\nimport { getCorrelationId } from \"./helpers/correlation.js\";\n\n// Re-exports\nexport { configure, getConfig } from \"./config.js\";\nexport type { NodeSDKConfig } from \"./config.js\";\nexport { expressRequestHandler, expressErrorHandler } from \"./integrations/express.js\";\nexport { withErrPulse } from \"./integrations/nextjs.js\";\nexport { flushAll } from \"./client.js\";\nexport { getCorrelationId } from \"./helpers/correlation.js\";\n\nconst cleanups: (() => void)[] = [];\n\nexport function init(options?: Partial<NodeSDKConfig>): void {\n if (options) configure(options);\n\n const config = getConfig();\n if (!config.enabled) return;\n\n if (config.captureUncaughtExceptions) {\n cleanups.push(installUncaughtExceptionHandler());\n }\n if (config.captureUnhandledRejections) {\n cleanups.push(installUnhandledRejectionHandler());\n }\n if (config.captureConsoleErrors) {\n cleanups.push(installConsoleErrorInterceptor());\n }\n if (config.monitorMemory) {\n cleanups.push(installMemoryMonitor());\n }\n\n // Flush on exit\n process.on(\"beforeExit\", () => {\n flushAll();\n });\n}\n\nexport function captureError(error: Error | string, extra?: Record<string, unknown>): string {\n const err = typeof error === \"string\" ? new Error(error) : error;\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function captureMessage(\n message: string,\n severity: \"info\" | \"warning\" | \"error\" = \"info\",\n extra?: Record<string, unknown>\n): string {\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message,\n source: ErrorSource.Backend,\n severity: severity as Severity,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function close(): void {\n for (const cleanup of cleanups) {\n cleanup();\n }\n cleanups.length = 0;\n flushAll();\n}\n\n// Auto-init with defaults when imported (can be overridden by calling init())\ninit();\n"],"mappings":";AKAA,SAAS,mBAAmB;ALArB,IAAK,cAAL,kBAAKA,iBAAL;AACLA,eAAA,SAAA,IAAU;AACVA,eAAA,UAAA,IAAW;AAFD,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAKL,IAAK,WAAL,kBAAKC,cAAL;AACLA,YAAA,OAAA,IAAQ;AACRA,YAAA,OAAA,IAAQ;AACRA,YAAA,SAAA,IAAU;AACVA,YAAA,MAAA,IAAO;AAJG,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAOL,IAAK,YAAL,kBAAKC,eAAL;AACLA,aAAA,mBAAA,IAAoB;AACpBA,aAAA,oBAAA,IAAqB;AACrBA,aAAA,WAAA,IAAY;AACZA,aAAA,cAAA,IAAe;AACfA,aAAA,YAAA,IAAa;AACbA,aAAA,eAAA,IAAgB;AAChBA,aAAA,cAAA,IAAe;AACfA,aAAA,eAAA,IAAgB;AAChBA,aAAA,QAAA,IAAS;AATC,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AEZL,IAAM,sBAAsB;AAG5B,IAAM,q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a,eAAe;AAAA,IAC5B,eAAe,iBAAiB;AAAA,IAChC,WAAW,UAAU,EAAE;AAAA,IACvB;AAAA,EACF;AAEA,eAAa,KAAK;AAClB,SAAO;AACT;AAEO,SAAS,QAAc;AAC5B,aAAW,WAAW,UAAU;AAC9B,YAAQ;AAAA,EACV;AACA,WAAS,SAAS;AAClB,WAAS;AACX;AAGA,KAAK;","names":["ErrorSource","Severity","ErrorType","installed"]} | ||
| {"version":3,"sources":["../../core/src/types/enums.ts","../../core/src/utils/fingerprint.ts","../../core/src/constants.ts","../../core/src/utils/normalize.ts","../../core/src/utils/sanitize.ts","../../core/src/utils/uuid.ts","../../core/src/explanations/patterns.ts","../../core/src/explanations/matcher.ts","../src/config.ts","../src/client.ts","../src/helpers/stack-parser.ts","../src/helpers/environment.ts","../src/instruments/uncaught-exception.ts","../src/instruments/unhandled-rejection.ts","../src/helpers/correlation.ts","../src/instruments/console-error.ts","../src/instruments/memory-monitor.ts","../src/integrations/express.ts","../src/integrations/nextjs.ts","../src/index.ts"],"sourcesContent":["export enum ErrorSource {\n Backend = \"backend\",\n Frontend = \"frontend\",\n}\n\nexport enum Severity {\n Fatal = \"fatal\",\n Error = \"error\",\n Warning = \"warning\",\n Info = \"info\",\n}\n\nexport enum ErrorType {\n UncaughtException = \"uncaught_exception\",\n UnhandledRejection = \"unhandled_rejection\",\n HttpError = \"http_error\",\n ConsoleError = \"console_error\",\n ReactError = \"react_error\",\n ResourceError = \"resource_error\",\n NetworkError = \"network_error\",\n MemoryWarning = \"memory_warning\",\n Manual = \"manual\",\n}\n\nexport enum ErrorStatus {\n Unresolved = \"unresolved\",\n Acknowledged = \"acknowledged\",\n Resolved = \"resolved\",\n Ignored = \"ignored\",\n}\n","import { createHash } from \"crypto\";\nimport type { ErrPulseEvent, StackFrame } from \"../types/error-event.js\";\nimport { normalizeMessage, getTopFrames } from \"./normalize.js\";\n\nfunction frameKey(frame: StackFrame): string {\n return `${frame.filename}:${frame.function}`;\n}\n\nexport function computeFingerprint(event: ErrPulseEvent): string {\n const parts: string[] = [event.type];\n\n parts.push(normalizeMessage(event.message));\n\n if (event.stackFrames && event.stackFrames.length > 0) {\n const topFrames = getTopFrames(event.stackFrames, 3);\n for (const frame of topFrames) {\n parts.push(frameKey(frame));\n }\n }\n\n const input = parts.join(\"\\n\");\n return createHash(\"sha256\").update(input).digest(\"hex\").slice(0, 32);\n}\n","export const DEFAULT_SERVER_PORT = 3800;\nexport const DEFAULT_DB_DIR = \".errpulse\";\nexport const DEFAULT_DB_FILENAME = \"errpulse.db\";\nexport const DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_SERVER_PORT}`;\nexport const EVENTS_ENDPOINT = \"/api/events\";\nexport const ERRORS_ENDPOINT = \"/api/errors\";\nexport const REQUESTS_ENDPOINT = \"/api/requests\";\nexport const HEALTH_ENDPOINT = \"/api/health\";\nexport const STATS_ENDPOINT = \"/api/stats\";\nexport const CORRELATION_HEADER = \"x-errpulse-correlation-id\";\nexport const PROJECT_HEADER = \"x-errpulse-project-id\";\nexport const MAX_MESSAGE_LENGTH = 2048;\nexport const MAX_STACK_FRAMES = 50;\nexport const BATCH_SIZE = 10;\nexport const BATCH_INTERVAL_MS = 100;\nexport const SENSITIVE_HEADERS = [\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"x-auth-token\",\n];\nexport const SENSITIVE_FIELDS = [\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"apiKey\",\n \"api_key\",\n \"accessToken\",\n \"access_token\",\n \"refreshToken\",\n \"refresh_token\",\n \"creditCard\",\n \"credit_card\",\n \"ssn\",\n \"cardNumber\",\n \"card_number\",\n \"cvv\",\n \"cvc\",\n];\n","import { MAX_MESSAGE_LENGTH, MAX_STACK_FRAMES } from \"../constants.js\";\nimport type { StackFrame } from \"../types/error-event.js\";\n\nexport function normalizeMessage(message: string): string {\n let normalized = message.trim();\n\n // Remove memory addresses (0x1a2b3c4d)\n normalized = normalized.replace(/0x[0-9a-fA-F]+/g, \"0x?\");\n\n // Remove specific line/column numbers from inline references\n normalized = normalized.replace(/:\\d+:\\d+/g, \":?:?\");\n\n // Remove UUIDs\n normalized = normalized.replace(\n /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,\n \"<uuid>\"\n );\n\n // Remove specific port numbers in URLs\n normalized = normalized.replace(/localhost:\\d+/g, \"localhost:?\");\n\n // Remove absolute file paths, keep filename\n normalized = normalized.replace(\n /(?:\\/[\\w.-]+)+\\/([\\w.-]+)/g,\n (_match, filename: string) => `<path>/${filename}`\n );\n\n // Truncate\n if (normalized.length > MAX_MESSAGE_LENGTH) {\n normalized = normalized.slice(0, MAX_MESSAGE_LENGTH) + \"...\";\n }\n\n return normalized;\n}\n\nexport function normalizeStackFrames(frames: StackFrame[]): StackFrame[] {\n return frames.slice(0, MAX_STACK_FRAMES);\n}\n\nexport function getInAppFrames(frames: StackFrame[]): StackFrame[] {\n return frames.filter((f) => f.inApp);\n}\n\nexport function getTopFrames(frames: StackFrame[], count: number): StackFrame[] {\n const inApp = getInAppFrames(frames);\n return inApp.length > 0 ? inApp.slice(0, count) : frames.slice(0, count);\n}\n","import { SENSITIVE_HEADERS, SENSITIVE_FIELDS } from \"../constants.js\";\n\nconst REDACTED = \"[Redacted]\";\n\nexport function sanitizeHeaders(headers: Record<string, string>): Record<string, string> {\n const sanitized: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (SENSITIVE_HEADERS.includes(key.toLowerCase())) {\n sanitized[key] = REDACTED;\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n\nexport function sanitizeObject(obj: unknown): unknown {\n if (obj === null || obj === undefined) return obj;\n if (typeof obj !== \"object\") return obj;\n\n if (Array.isArray(obj)) {\n return obj.map(sanitizeObject);\n }\n\n const sanitized: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n if (SENSITIVE_FIELDS.some((f) => key.toLowerCase().includes(f.toLowerCase()))) {\n sanitized[key] = REDACTED;\n } else if (typeof value === \"object\" && value !== null) {\n sanitized[key] = sanitizeObject(value);\n } else {\n sanitized[key] = value;\n }\n }\n return sanitized;\n}\n","import { randomBytes } from \"crypto\";\n\nexport function generateEventId(): string {\n return randomBytes(16).toString(\"hex\");\n}\n\nexport function generateCorrelationId(): string {\n return randomBytes(8).toString(\"hex\");\n}\n","export interface ErrorPattern {\n pattern: RegExp;\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport const ERROR_PATTERNS: ErrorPattern[] = [\n // === Type Errors ===\n {\n pattern: /Cannot read propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Reference Access\",\n explanation:\n \"Your code tried to access a property on something that is undefined or null. This usually means a variable wasn't initialized, an API returned unexpected data, or an object was accessed before it was ready.\",\n suggestion:\n \"Add optional chaining (?.) or a null check before accessing the property. For example: obj?.property instead of obj.property.\",\n },\n {\n pattern: /Cannot set propert(?:y|ies) of (undefined|null)/i,\n title: \"Null Assignment\",\n explanation: \"Your code tried to set a property on something that is undefined or null.\",\n suggestion:\n \"Check that the object exists before assigning to it. Initialize the object first if needed.\",\n },\n {\n pattern: /(\\w+) is not a function/i,\n title: \"Not a Function\",\n explanation:\n \"Your code tried to call something as a function, but it's not one. This often happens when a method name is misspelled, an import is wrong, or a callback wasn't passed correctly.\",\n suggestion:\n \"Check the spelling, verify the import, and make sure the value is actually a function before calling it.\",\n },\n {\n pattern: /(\\w+) is not defined/i,\n title: \"Undefined Variable\",\n explanation:\n \"Your code references a variable that doesn't exist in the current scope. This could be a typo, a missing import, or a scoping issue.\",\n suggestion:\n \"Check for typos in the variable name and ensure it's imported or declared before use.\",\n },\n {\n pattern: /Cannot access '(\\w+)' before initialization/i,\n title: \"Temporal Dead Zone\",\n explanation:\n \"A variable declared with let or const was used before its declaration was reached. JavaScript hoists the declaration but not the initialization.\",\n suggestion:\n \"Move the variable declaration before its first use, or restructure the code to avoid the circular dependency.\",\n },\n {\n pattern: /Assignment to constant variable/i,\n title: \"Constant Reassignment\",\n explanation: \"Your code tried to reassign a variable declared with const.\",\n suggestion: \"Use let instead of const if you need to reassign the variable.\",\n },\n {\n pattern: /Maximum call stack size exceeded/i,\n title: \"Stack Overflow\",\n explanation:\n \"A function called itself recursively without a proper exit condition, causing an infinite loop of calls until the stack ran out of space.\",\n suggestion:\n \"Add or fix the base case in your recursive function. Check for unintended circular calls between functions.\",\n },\n\n // === Syntax / Module Errors ===\n {\n pattern: /Unexpected token/i,\n title: \"Syntax Error\",\n explanation:\n \"The JavaScript parser found a character it didn't expect. This usually means a missing bracket, comma, or quote somewhere.\",\n suggestion:\n \"Check the file around the reported line for missing or extra brackets, commas, semicolons, or quotes.\",\n },\n {\n pattern: /Cannot find module '(.+)'/i,\n title: \"Module Not Found\",\n explanation:\n \"Node.js couldn't find the module you tried to import. Either the package isn't installed, the file path is wrong, or the module name is misspelled.\",\n suggestion:\n \"Run npm install to ensure all dependencies are installed. Check the import path for typos.\",\n },\n {\n pattern: /SyntaxError: .* is not valid JSON/i,\n title: \"Invalid JSON\",\n explanation:\n \"Your code tried to parse a string as JSON, but the string isn't valid JSON. This often happens when an API returns HTML (like an error page) instead of JSON.\",\n suggestion:\n \"Log the raw response before parsing. Check that the API endpoint is correct and returning JSON.\",\n },\n\n // === Network & HTTP Errors ===\n {\n pattern: /ECONNREFUSED/i,\n title: \"Connection Refused\",\n explanation:\n \"Your app tried to connect to a server that isn't accepting connections. The target service is either not running, listening on a different port, or blocked by a firewall.\",\n suggestion: \"Make sure the target service is running and listening on the expected host:port.\",\n },\n {\n pattern: /ECONNRESET/i,\n title: \"Connection Reset\",\n explanation:\n \"The remote server abruptly closed the connection. This can happen due to server crashes, timeouts, or network issues.\",\n suggestion: \"Add retry logic with backoff. Check the remote server's logs for errors.\",\n },\n {\n pattern: /ETIMEDOUT/i,\n title: \"Connection Timed Out\",\n explanation:\n \"The connection to the remote server took too long and was abandoned. The server might be overloaded or unreachable.\",\n suggestion: \"Increase the timeout, check network connectivity, or add retry logic.\",\n },\n {\n pattern: /ENOTFOUND/i,\n title: \"DNS Lookup Failed\",\n explanation:\n \"The hostname couldn't be resolved to an IP address. The domain name is wrong or DNS is not working.\",\n suggestion: \"Check the hostname for typos. Verify DNS resolution is working.\",\n },\n {\n pattern: /EADDRINUSE/i,\n title: \"Port Already in Use\",\n explanation: \"Your app tried to listen on a port that's already taken by another process.\",\n suggestion: \"Use a different port, or find and stop the process using that port: lsof -i :PORT\",\n },\n {\n pattern: /fetch failed|Failed to fetch/i,\n title: \"Fetch Failed\",\n explanation:\n \"A network request failed completely. This usually means the server is unreachable, CORS blocked the request, or there's no internet connection.\",\n suggestion:\n \"Check that the URL is correct, the server is running, and CORS is configured if calling from a browser.\",\n },\n {\n pattern: /Network request failed/i,\n title: \"Network Error\",\n explanation:\n \"A network request could not complete. The server may be down, the URL may be wrong, or the network may be unavailable.\",\n suggestion: \"Verify the target URL and network connectivity.\",\n },\n {\n pattern: /status code 4\\d{2}/i,\n title: \"Client Error (4xx)\",\n explanation:\n \"The server rejected the request due to a client-side issue — bad request data, missing auth, or accessing a resource that doesn't exist.\",\n suggestion: \"Check the request URL, headers, authentication, and body for correctness.\",\n },\n {\n pattern: /status code 5\\d{2}/i,\n title: \"Server Error (5xx)\",\n explanation: \"The server encountered an internal error while processing the request.\",\n suggestion: \"Check the server logs for the root cause. This is a backend issue.\",\n },\n\n // === Database Errors ===\n {\n pattern: /ER_DUP_ENTRY|duplicate key|unique constraint/i,\n title: \"Duplicate Entry\",\n explanation:\n \"A database insert or update violated a unique constraint — you're trying to insert data that already exists.\",\n suggestion: \"Use upsert/ON CONFLICT, or check for existing records before inserting.\",\n },\n {\n pattern: /ER_NO_SUCH_TABLE|relation .* does not exist|no such table/i,\n title: \"Table Not Found\",\n explanation: \"The query references a database table that doesn't exist.\",\n suggestion: \"Run your database migrations. Check that the table name is spelled correctly.\",\n },\n {\n pattern: /ER_PARSE_ERROR|syntax error at or near/i,\n title: \"SQL Syntax Error\",\n explanation: \"Your SQL query has a syntax error.\",\n suggestion: \"Check the SQL query for typos, missing commas, or incorrect keywords.\",\n },\n {\n pattern: /SQLITE_BUSY/i,\n title: \"Database Busy\",\n explanation:\n \"SQLite couldn't acquire a lock because another connection is writing. This happens with concurrent writes.\",\n suggestion: \"Enable WAL mode, reduce write contention, or add retry logic.\",\n },\n {\n pattern: /connection.*refused.*database|Can't connect to/i,\n title: \"Database Connection Failed\",\n explanation:\n \"Your app couldn't connect to the database server. The database might not be running or the connection string is wrong.\",\n suggestion:\n \"Verify the database is running and the connection string (host, port, credentials) is correct.\",\n },\n\n // === React / Frontend Errors ===\n {\n pattern: /Minified React error #(\\d+)/i,\n title: \"React Production Error\",\n explanation:\n \"React threw an error in production mode. The error is minified — check the React error decoder for details.\",\n suggestion:\n \"Look up the error number at https://reactjs.org/docs/error-decoder.html for the full message.\",\n },\n {\n pattern: /Hydration failed|Text content does not match|did not match/i,\n title: \"Hydration Mismatch\",\n explanation:\n \"The HTML rendered on the server doesn't match what React tried to render on the client. This causes the page to re-render completely.\",\n suggestion:\n \"Ensure server and client render identical output. Avoid using Date.now(), Math.random(), or browser-only APIs during initial render.\",\n },\n {\n pattern: /Invalid hook call/i,\n title: \"Invalid React Hook Call\",\n explanation:\n \"A React hook was called outside of a function component, or you have multiple copies of React in your bundle.\",\n suggestion:\n \"Only call hooks at the top level of function components. Check for duplicate React versions with npm ls react.\",\n },\n {\n pattern: /Objects are not valid as a React child/i,\n title: \"Invalid React Child\",\n explanation: \"You tried to render a plain object as a React child, which isn't allowed.\",\n suggestion:\n \"Convert the object to a string (JSON.stringify) or render its properties individually.\",\n },\n {\n pattern: /Each child in a list should have a unique \"key\" prop/i,\n title: \"Missing React Key\",\n explanation:\n \"When rendering a list of elements, each item needs a unique key prop for React's reconciliation algorithm.\",\n suggestion: \"Add a unique key prop to each item. Use a stable ID, not array index.\",\n },\n {\n pattern: /ResizeObserver loop/i,\n title: \"ResizeObserver Loop\",\n explanation:\n \"A ResizeObserver callback caused another resize, creating an infinite loop. This is usually harmless but noisy.\",\n suggestion: \"This is often safe to ignore. If it causes issues, debounce the resize handler.\",\n },\n\n // === Authentication / Authorization ===\n {\n pattern: /jwt (expired|malformed|invalid)/i,\n title: \"JWT Error\",\n explanation:\n \"The JSON Web Token is invalid — it may be expired, malformed, or signed with the wrong key.\",\n suggestion: \"Check token expiration, refresh the token, or verify the signing key matches.\",\n },\n {\n pattern: /unauthorized|401/i,\n title: \"Unauthorized\",\n explanation: \"The request lacks valid authentication credentials.\",\n suggestion: \"Ensure the auth token is present and valid. Check for expired sessions.\",\n },\n {\n pattern: /forbidden|403/i,\n title: \"Forbidden\",\n explanation:\n \"The server understood the request but refuses to authorize it. The user doesn't have permission.\",\n suggestion: \"Check user permissions and roles. Verify the user has access to this resource.\",\n },\n\n // === CORS ===\n {\n pattern: /CORS|Access-Control-Allow-Origin|cross-origin/i,\n title: \"CORS Error\",\n explanation:\n \"The browser blocked a request to a different origin because the server didn't include the right CORS headers.\",\n suggestion:\n \"Configure the server to send Access-Control-Allow-Origin headers. For development, use a proxy or cors middleware.\",\n },\n\n // === Memory ===\n {\n pattern: /heap out of memory|ENOMEM|JavaScript heap/i,\n title: \"Out of Memory\",\n explanation:\n \"The process ran out of available memory. This could be a memory leak or processing too much data at once.\",\n suggestion:\n \"Increase memory limit with --max-old-space-size, check for memory leaks, or process data in chunks.\",\n },\n {\n pattern: /memory usage.*threshold|high memory/i,\n title: \"High Memory Usage\",\n explanation: \"The application's memory usage has exceeded the warning threshold.\",\n suggestion:\n \"Monitor for memory leaks. Consider restarting the process periodically or increasing available memory.\",\n },\n\n // === File System ===\n {\n pattern: /ENOENT|no such file or directory/i,\n title: \"File Not Found\",\n explanation: \"Your code tried to access a file or directory that doesn't exist.\",\n suggestion: \"Check the file path for typos. Ensure the file exists before accessing it.\",\n },\n {\n pattern: /EACCES|permission denied/i,\n title: \"Permission Denied\",\n explanation: \"The process doesn't have permission to access the file or resource.\",\n suggestion: \"Check file permissions. Run with appropriate user/group or fix file ownership.\",\n },\n {\n pattern: /EMFILE|too many open files/i,\n title: \"Too Many Open Files\",\n explanation:\n \"The process has opened more files than the OS allows. This often indicates a file descriptor leak.\",\n suggestion: \"Close files after use. Increase the ulimit, or check for leaked file descriptors.\",\n },\n\n // === Timeout ===\n {\n pattern: /timeout|timed out|ESOCKETTIMEDOUT/i,\n title: \"Operation Timed Out\",\n explanation:\n \"An operation took too long and was cancelled. The target service might be slow or overloaded.\",\n suggestion:\n \"Increase the timeout value, add retry logic, or investigate why the operation is slow.\",\n },\n\n // === Encoding / Parsing ===\n {\n pattern: /URIError|URI malformed/i,\n title: \"Malformed URI\",\n explanation: \"A URL encoding/decoding operation received an invalid URI.\",\n suggestion:\n \"Check the input for invalid characters. Use encodeURIComponent/decodeURIComponent correctly.\",\n },\n {\n pattern: /RangeError.*Invalid array length/i,\n title: \"Invalid Array Length\",\n explanation: \"An array was created with an invalid length (negative or too large).\",\n suggestion: \"Check the value being used as the array length.\",\n },\n\n // === Catch-all ===\n {\n pattern: /TypeError/i,\n title: \"Type Error\",\n explanation:\n \"A value is not the type that was expected. This often means using the wrong method on the wrong data type.\",\n suggestion:\n \"Check what type the variable actually is (using typeof or console.log) and handle it appropriately.\",\n },\n {\n pattern: /ReferenceError/i,\n title: \"Reference Error\",\n explanation: \"Your code references something that doesn't exist in the current scope.\",\n suggestion: \"Check for typos, missing imports, or variables used outside their scope.\",\n },\n {\n pattern: /SyntaxError/i,\n title: \"Syntax Error\",\n explanation: \"The code has a syntax error that prevents it from being parsed.\",\n suggestion:\n \"Check for missing brackets, quotes, commas, or other syntax issues around the reported location.\",\n },\n];\n","import { ERROR_PATTERNS, type ErrorPattern } from \"./patterns.js\";\n\nexport interface ErrorExplanation {\n title: string;\n explanation: string;\n suggestion: string;\n}\n\nexport function explainError(message: string): ErrorExplanation | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return {\n title: pattern.title,\n explanation: pattern.explanation,\n suggestion: pattern.suggestion,\n };\n }\n }\n return null;\n}\n\nexport function matchPattern(message: string): ErrorPattern | null {\n for (const pattern of ERROR_PATTERNS) {\n if (pattern.pattern.test(message)) {\n return pattern;\n }\n }\n return null;\n}\n","import { DEFAULT_SERVER_URL } from \"@errpulse/core\";\nimport type { ErrPulseEvent } from \"@errpulse/core\";\n\nexport interface NodeSDKConfig {\n serverUrl: string;\n projectId?: string;\n enabled: boolean;\n sampleRate: number;\n beforeSend?: (event: ErrPulseEvent) => ErrPulseEvent | null;\n captureConsoleErrors: boolean;\n captureUncaughtExceptions: boolean;\n captureUnhandledRejections: boolean;\n monitorMemory: boolean;\n memoryThresholdMB: number;\n memoryCheckIntervalMs: number;\n}\n\nconst defaultConfig: NodeSDKConfig = {\n serverUrl: DEFAULT_SERVER_URL,\n enabled: true,\n sampleRate: 1.0,\n captureConsoleErrors: true,\n captureUncaughtExceptions: true,\n captureUnhandledRejections: true,\n monitorMemory: true,\n memoryThresholdMB: 512,\n memoryCheckIntervalMs: 30000,\n};\n\nlet currentConfig: NodeSDKConfig = { ...defaultConfig };\n\nexport function configure(partial: Partial<NodeSDKConfig>): NodeSDKConfig {\n currentConfig = { ...currentConfig, ...partial };\n return currentConfig;\n}\n\nexport function getConfig(): NodeSDKConfig {\n return currentConfig;\n}\n","import { EVENTS_ENDPOINT, BATCH_SIZE, BATCH_INTERVAL_MS, type ErrPulseEvent } from \"@errpulse/core\";\nimport { getConfig } from \"./config.js\";\n\nlet buffer: ErrPulseEvent[] = [];\nlet flushTimer: ReturnType<typeof setTimeout> | null = null;\nlet isFlushing = false;\n\nasync function sendBatch(events: ErrPulseEvent[]): Promise<void> {\n const config = getConfig();\n if (!config.enabled || events.length === 0) return;\n\n const url =\n events.length === 1\n ? `${config.serverUrl}${EVENTS_ENDPOINT}`\n : `${config.serverUrl}${EVENTS_ENDPOINT}/batch`;\n const body = events.length === 1 ? events[0] : events;\n\n try {\n const resp = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(5000),\n });\n\n if (!resp.ok) {\n console.warn(`[ErrPulse] Failed to send events: ${resp.status}`);\n }\n } catch {\n // Silently fail — SDK must never crash host app\n }\n}\n\nfunction scheduleFlush(): void {\n if (flushTimer) return;\n flushTimer = setTimeout(() => {\n flushTimer = null;\n flush();\n }, BATCH_INTERVAL_MS);\n}\n\nasync function flush(): Promise<void> {\n if (isFlushing || buffer.length === 0) return;\n isFlushing = true;\n\n const batch = buffer.splice(0);\n await sendBatch(batch);\n\n isFlushing = false;\n\n // If more events accumulated during flush, schedule another\n if (buffer.length > 0) {\n scheduleFlush();\n }\n}\n\nexport function enqueueEvent(event: ErrPulseEvent): void {\n const config = getConfig();\n if (!config.enabled) return;\n\n // Sample rate check\n if (config.sampleRate < 1 && Math.random() > config.sampleRate) return;\n\n // Inject projectId\n if (config.projectId && !event.projectId) {\n event.projectId = config.projectId;\n }\n\n // beforeSend hook\n if (config.beforeSend) {\n const result = config.beforeSend(event);\n if (!result) return;\n buffer.push(result);\n } else {\n buffer.push(event);\n }\n\n if (buffer.length >= BATCH_SIZE) {\n flush();\n } else {\n scheduleFlush();\n }\n}\n\nexport async function flushAll(): Promise<void> {\n if (flushTimer) {\n clearTimeout(flushTimer);\n flushTimer = null;\n }\n await flush();\n}\n\n// Send a request log entry\nexport async function sendRequest(entry: {\n method: string;\n url: string;\n statusCode?: number;\n duration?: number;\n timestamp: string;\n correlationId?: string;\n errorEventId?: string;\n headers?: Record<string, string>;\n responseHeaders?: Record<string, string>;\n requestBody?: string;\n responseBody?: string;\n source?: string;\n projectId?: string;\n}): Promise<void> {\n const config = getConfig();\n if (!config.enabled) return;\n\n const payload = {\n ...entry,\n projectId: entry.projectId ?? config.projectId,\n };\n\n try {\n await fetch(`${config.serverUrl}${EVENTS_ENDPOINT}/request`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(5000),\n });\n } catch {\n // Silently fail\n }\n}\n","import type { StackFrame } from \"@errpulse/core\";\n\nconst NODE_STACK_RE = /^\\s*at\\s+(?:(.+?)\\s+\\()?(.+?):(\\d+):(\\d+)\\)?$/;\n\nexport function parseStack(stack: string): StackFrame[] {\n const frames: StackFrame[] = [];\n\n for (const line of stack.split(\"\\n\")) {\n const match = NODE_STACK_RE.exec(line);\n if (!match) continue;\n\n const [, fn, filename, lineno, colno] = match;\n\n const isNodeInternal =\n filename.startsWith(\"node:\") ||\n filename.includes(\"node_modules\") ||\n !filename.startsWith(\"/\");\n\n frames.push({\n function: fn || \"<anonymous>\",\n filename,\n lineno: Number(lineno),\n colno: Number(colno),\n inApp: !isNodeInternal,\n });\n }\n\n return frames;\n}\n","import type { EnvironmentInfo } from \"@errpulse/core\";\nimport os from \"os\";\n\nexport function getEnvironment(): EnvironmentInfo {\n const mem = process.memoryUsage();\n return {\n runtime: \"node\",\n runtimeVersion: process.version,\n nodeVersion: process.version,\n os: `${os.type()} ${os.release()}`,\n arch: os.arch(),\n memoryUsage: {\n heapUsed: mem.heapUsed,\n heapTotal: mem.heapTotal,\n rss: mem.rss,\n },\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, flushAll } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUncaughtExceptionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = async (error: Error) => {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UncaughtException,\n message: error.message || String(error),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Fatal,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n await flushAll();\n };\n\n process.on(\"uncaughtException\", handler);\n\n return () => {\n process.removeListener(\"uncaughtException\", handler);\n installed = false;\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\nlet installed = false;\n\nexport function installUnhandledRejectionHandler(): () => void {\n if (installed) return () => {};\n installed = true;\n\n const handler = (reason: unknown) => {\n const error = reason instanceof Error ? reason : new Error(String(reason));\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.UnhandledRejection,\n message: error.message || String(reason),\n stack: error.stack,\n stackFrames: error.stack ? parseStack(error.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n };\n\n enqueueEvent(event);\n };\n\n process.on(\"unhandledRejection\", handler);\n\n return () => {\n process.removeListener(\"unhandledRejection\", handler);\n installed = false;\n };\n}\n","import { AsyncLocalStorage } from \"async_hooks\";\nimport { CORRELATION_HEADER, generateCorrelationId } from \"@errpulse/core\";\n\nconst correlationStore = new AsyncLocalStorage<string>();\n\nexport function getCorrelationId(): string | undefined {\n return correlationStore.getStore();\n}\n\nexport function runWithCorrelation<T>(correlationId: string, fn: () => T): T {\n return correlationStore.run(correlationId, fn);\n}\n\nexport function extractOrCreateCorrelationId(\n headers: Record<string, string | string[] | undefined>\n): string {\n const existing = headers[CORRELATION_HEADER];\n if (typeof existing === \"string\" && existing) {\n return existing;\n }\n return generateCorrelationId();\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getCorrelationId } from \"../helpers/correlation.js\";\n\nlet originalConsoleError: typeof console.error | null = null;\n\nexport function installConsoleErrorInterceptor(): () => void {\n if (originalConsoleError) return () => {};\n\n originalConsoleError = console.error;\n\n console.error = (...args: unknown[]) => {\n // Always call original\n originalConsoleError!.apply(console, args);\n\n try {\n const message = args.map((a) => (typeof a === \"string\" ? a : JSON.stringify(a))).join(\" \");\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.ConsoleError,\n message,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash the host app\n }\n };\n\n return () => {\n if (originalConsoleError) {\n console.error = originalConsoleError;\n originalConsoleError = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent } from \"../client.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { getConfig } from \"../config.js\";\n\nlet intervalId: ReturnType<typeof setInterval> | null = null;\n\nexport function installMemoryMonitor(): () => void {\n if (intervalId) return () => {};\n\n const config = getConfig();\n\n intervalId = setInterval(() => {\n try {\n const mem = process.memoryUsage();\n const heapUsedMB = mem.heapUsed / (1024 * 1024);\n\n if (heapUsedMB > config.memoryThresholdMB) {\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.MemoryWarning,\n message: `High memory usage: ${Math.round(heapUsedMB)}MB heap used (threshold: ${config.memoryThresholdMB}MB)`,\n source: ErrorSource.Backend,\n severity: Severity.Warning,\n environment: getEnvironment(),\n extra: {\n heapUsedMB: Math.round(heapUsedMB),\n heapTotalMB: Math.round(mem.heapTotal / (1024 * 1024)),\n rssMB: Math.round(mem.rss / (1024 * 1024)),\n threshold: config.memoryThresholdMB,\n },\n };\n\n enqueueEvent(event);\n }\n } catch {\n // Never crash host app\n }\n }, config.memoryCheckIntervalMs);\n\n return () => {\n if (intervalId) {\n clearInterval(intervalId);\n intervalId = null;\n }\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n sanitizeHeaders,\n sanitizeObject,\n CORRELATION_HEADER,\n type ErrPulseEvent,\n type RequestContext,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\nimport { extractOrCreateCorrelationId, runWithCorrelation } from \"../helpers/correlation.js\";\n\ntype Request = {\n method: string;\n url: string;\n originalUrl?: string;\n path?: string;\n headers: Record<string, string | string[] | undefined>;\n query?: Record<string, string>;\n body?: unknown;\n ip?: string;\n};\n\ntype Response = {\n statusCode: number;\n on(event: string, listener: () => void): void;\n getHeaders(): Record<string, string | string[] | number | undefined>;\n write: (...args: unknown[]) => boolean;\n end: (...args: unknown[]) => void;\n};\n\ntype NextFunction = (err?: unknown) => void;\n\n// Max size for request body capture (16 KB) to avoid performance issues\nconst MAX_BODY_SIZE = 16 * 1024;\n\nfunction flattenHeaders(\n headers: Record<string, string | string[] | number | undefined>\n): Record<string, string> {\n const flat: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (value === undefined) continue;\n flat[key] = Array.isArray(value) ? value.join(\", \") : String(value);\n }\n return flat;\n}\n\nfunction captureBody(body: unknown): string | undefined {\n if (body === undefined || body === null) return undefined;\n try {\n const str = typeof body === \"string\" ? body : JSON.stringify(sanitizeObject(body));\n // Truncate if too large\n if (str.length > MAX_BODY_SIZE) {\n return str.slice(0, MAX_BODY_SIZE) + \"...[truncated]\";\n }\n return str;\n } catch {\n return undefined;\n }\n}\n\nexport function expressRequestHandler() {\n return (req: Request, res: Response, next: NextFunction): void => {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n const startTime = Date.now();\n\n // Capture request headers and body early (before body may be consumed)\n const reqHeaders = sanitizeHeaders(\n flattenHeaders(req.headers as Record<string, string | string[] | number | undefined>)\n );\n const reqBody = captureBody(req.body);\n\n // Intercept response body by patching write/end (size-limited)\n const resChunks: Buffer[] = [];\n let resBodySize = 0;\n let resBodyOverflow = false;\n const origWrite = res.write;\n const origEnd = res.end;\n\n res.write = (chunk: unknown, ...args: unknown[]): boolean => {\n if (!resBodyOverflow && chunk) {\n const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));\n resBodySize += buf.length;\n if (resBodySize <= MAX_BODY_SIZE) {\n resChunks.push(buf);\n } else {\n resBodyOverflow = true;\n }\n }\n return (origWrite as Function).apply(res, [chunk, ...args]) as boolean;\n };\n\n res.end = (chunk: unknown, ...args: unknown[]): void => {\n if (!resBodyOverflow && chunk && typeof chunk !== \"function\") {\n const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));\n resBodySize += buf.length;\n if (resBodySize <= MAX_BODY_SIZE) {\n resChunks.push(buf);\n } else {\n resBodyOverflow = true;\n }\n }\n (origEnd as Function).apply(res, [chunk, ...args]);\n };\n\n // Track response completion to log request\n res.on(\"finish\", () => {\n try {\n const duration = Date.now() - startTime;\n\n // Capture response headers\n let resHeaders: Record<string, string> | undefined;\n try {\n resHeaders = flattenHeaders(res.getHeaders());\n } catch {\n // getHeaders may not exist in all environments\n }\n\n // Build response body string\n let resBody: string | undefined;\n if (resChunks.length > 0) {\n resBody = Buffer.concat(resChunks).toString(\"utf-8\");\n if (resBodyOverflow) {\n resBody += \"...[truncated]\";\n }\n }\n\n sendRequest({\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n headers: reqHeaders,\n responseHeaders: resHeaders,\n requestBody: reqBody,\n responseBody: resBody,\n source: \"backend\",\n });\n } catch {\n // Never crash host app\n }\n });\n\n // Run the rest of the middleware chain with correlation context\n runWithCorrelation(correlationId, () => next());\n };\n}\n\nexport function expressErrorHandler() {\n return (err: Error, req: Request, res: Response, next: NextFunction): void => {\n try {\n const correlationId = extractOrCreateCorrelationId(\n req.headers as Record<string, string | string[] | undefined>\n );\n\n const requestContext: RequestContext = {\n method: req.method,\n url: req.originalUrl || req.url,\n statusCode: res.statusCode >= 400 ? res.statusCode : 500,\n headers: sanitizeHeaders(\n Object.fromEntries(\n Object.entries(req.headers).map(([k, v]) => [\n k,\n Array.isArray(v) ? v.join(\", \") : v || \"\",\n ])\n )\n ),\n query: req.query as Record<string, string>,\n ip: req.ip,\n userAgent: req.headers[\"user-agent\"] as string,\n };\n\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: requestContext,\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n } catch {\n // Never crash host app\n }\n\n next(err);\n };\n}\n","import {\n ErrorType,\n ErrorSource,\n Severity,\n generateEventId,\n CORRELATION_HEADER,\n generateCorrelationId,\n type ErrPulseEvent,\n} from \"@errpulse/core\";\nimport { enqueueEvent, sendRequest } from \"../client.js\";\nimport { parseStack } from \"../helpers/stack-parser.js\";\nimport { getEnvironment } from \"../helpers/environment.js\";\n\ntype NextRequest = {\n method: string;\n url: string;\n headers: { get(name: string): string | null };\n nextUrl?: { pathname: string };\n};\n\ntype NextResponse = {\n status: number;\n};\n\n/**\n * Wraps a Next.js API route handler to capture errors and log requests.\n *\n * Usage:\n * import { withErrPulse } from '@errpulse/node'\n * export const GET = withErrPulse(async (req) => { ... })\n */\nexport function withErrPulse<T extends (...args: unknown[]) => Promise<unknown>>(handler: T): T {\n return (async (...args: unknown[]) => {\n const req = args[0] as NextRequest | undefined;\n const method = req?.method ?? \"UNKNOWN\";\n const url = req?.nextUrl?.pathname ?? req?.url ?? \"/\";\n const correlationId = req?.headers?.get(CORRELATION_HEADER) ?? generateCorrelationId();\n const startTime = Date.now();\n\n try {\n const result = await handler(...args);\n const duration = Date.now() - startTime;\n\n // Log the request\n const statusCode = (result as NextResponse)?.status ?? 200;\n sendRequest({\n method,\n url,\n statusCode,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n return result;\n } catch (error) {\n const duration = Date.now() - startTime;\n const err = error instanceof Error ? error : new Error(String(error));\n\n // Log the failed request\n sendRequest({\n method,\n url,\n statusCode: 500,\n duration,\n timestamp: new Date().toISOString(),\n correlationId,\n source: \"backend\",\n });\n\n // Capture the error\n const event: ErrPulseEvent = {\n eventId: generateEventId(),\n timestamp: new Date().toISOString(),\n type: ErrorType.HttpError,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n request: {\n method,\n url,\n statusCode: 500,\n duration,\n },\n environment: getEnvironment(),\n correlationId,\n };\n\n enqueueEvent(event);\n throw error;\n }\n }) as T;\n}\n","import type { ErrPulseEvent } from \"@errpulse/core\";\nimport { ErrorType, ErrorSource, Severity, generateEventId } from \"@errpulse/core\";\nimport { configure, getConfig, type NodeSDKConfig } from \"./config.js\";\nimport { enqueueEvent, flushAll } from \"./client.js\";\nimport { installUncaughtExceptionHandler } from \"./instruments/uncaught-exception.js\";\nimport { installUnhandledRejectionHandler } from \"./instruments/unhandled-rejection.js\";\nimport { installConsoleErrorInterceptor } from \"./instruments/console-error.js\";\nimport { installMemoryMonitor } from \"./instruments/memory-monitor.js\";\nimport { parseStack } from \"./helpers/stack-parser.js\";\nimport { getEnvironment } from \"./helpers/environment.js\";\nimport { getCorrelationId } from \"./helpers/correlation.js\";\n\n// Re-exports\nexport { configure, getConfig } from \"./config.js\";\nexport type { NodeSDKConfig } from \"./config.js\";\nexport { expressRequestHandler, expressErrorHandler } from \"./integrations/express.js\";\nexport { withErrPulse } from \"./integrations/nextjs.js\";\nexport { flushAll } from \"./client.js\";\nexport { getCorrelationId } from \"./helpers/correlation.js\";\n\nconst cleanups: (() => void)[] = [];\n\nexport function init(options?: Partial<NodeSDKConfig>): void {\n if (options) configure(options);\n\n const config = getConfig();\n if (!config.enabled) return;\n\n if (config.captureUncaughtExceptions) {\n cleanups.push(installUncaughtExceptionHandler());\n }\n if (config.captureUnhandledRejections) {\n cleanups.push(installUnhandledRejectionHandler());\n }\n if (config.captureConsoleErrors) {\n cleanups.push(installConsoleErrorInterceptor());\n }\n if (config.monitorMemory) {\n cleanups.push(installMemoryMonitor());\n }\n\n // Flush on exit\n process.on(\"beforeExit\", () => {\n flushAll();\n });\n}\n\nexport function captureError(error: Error | string, extra?: Record<string, unknown>): string {\n const err = typeof error === \"string\" ? new Error(error) : error;\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message: err.message || String(err),\n stack: err.stack,\n stackFrames: err.stack ? parseStack(err.stack) : undefined,\n source: ErrorSource.Backend,\n severity: Severity.Error,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function captureMessage(\n message: string,\n severity: \"info\" | \"warning\" | \"error\" = \"info\",\n extra?: Record<string, unknown>\n): string {\n const eventId = generateEventId();\n\n const event: ErrPulseEvent = {\n eventId,\n timestamp: new Date().toISOString(),\n type: ErrorType.Manual,\n message,\n source: ErrorSource.Backend,\n severity: severity as Severity,\n environment: getEnvironment(),\n correlationId: getCorrelationId(),\n projectId: getConfig().projectId,\n extra,\n };\n\n enqueueEvent(event);\n return eventId;\n}\n\nexport function close(): void {\n for (const cleanup of cleanups) {\n cleanup();\n }\n cleanups.length = 0;\n flushAll();\n}\n\n// Auto-init with defaults when imported (can be overridden by calling init())\ninit();\n"],"mappings":";AKAA,SAAS,mBAAmB;ALArB,IAAK,cAAL,kBAAKA,iBAAL;AACLA,eAAA,SAAA,IAAU;AACVA,eAAA,UAAA,IAAW;AAFD,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAK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,IAClC,OAAO,IAAI;AAAA,IACX,aAAa,IAAI,QAAQ,WAAW,IAAI,KAAK,IAAI;AAAA,IACjD,QAAQ,YAAY;AAAA,IACpB,UAAU,SAAS;AAAA,IACnB,aAAa,eAAe;AAAA,IAC5B,eAAe,iBAAiB;AAAA,IAChC,WAAW,UAAU,EAAE;AAAA,IACvB;AAAA,EACF;AAEA,eAAa,KAAK;AAClB,SAAO;AACT;AAEO,SAAS,eACd,SACA,WAAyC,QACzC,OACQ;AACR,QAAM,UAAU,gBAAgB;AAEhC,QAAM,QAAuB;AAAA,IAC3B;AAAA,IACA,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,IAClC,MAAM,UAAU;AAAA,IAChB;AAAA,IACA,QAAQ,YAAY;AAAA,IACpB;AAAA,IACA,aAAa,eAAe;AAAA,IAC5B,eAAe,iBAAiB;AAAA,IAChC,WAAW,UAAU,EAAE;AAAA,IACvB;AAAA,EACF;AAEA,eAAa,KAAK;AAClB,SAAO;AACT;AAEO,SAAS,QAAc;AAC5B,aAAW,WAAW,UAAU;AAC9B,YAAQ;AAAA,EACV;AACA,WAAS,SAAS;AAClB,WAAS;AACX;AAGA,KAAK;","names":["ErrorSource","Severity","ErrorType","installed"]} |
+2
-2
| { | ||
| "name": "@errpulse/node", | ||
| "version": "0.2.0", | ||
| "version": "0.3.0", | ||
| "description": "ErrPulse Node.js backend SDK — catch every backend error automatically", | ||
@@ -55,3 +55,3 @@ "license": "MIT", | ||
| "vitest": "^2.1.8", | ||
| "@errpulse/core": "0.2.0" | ||
| "@errpulse/core": "0.3.0" | ||
| }, | ||
@@ -58,0 +58,0 @@ "peerDependencies": { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
167214
11.46%1386
18.56%