Files
klz-cables.com/.pnpm-store/v10/files/db/6b007a013a791d16a4068791196e70e21ade12b564ef40f24710f0e8c553eeb79dddeaaa1ec398e4bfcfeb120790dff4b5376dfe77d977b35f967bfaa74b5a
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

101 lines
2.7 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const diagnosticsChannel = require('node:diagnostics_channel');
const core = require('@sentry/core');
const INTEGRATION_NAME = 'ChildProcess';
/**
* Capture breadcrumbs and events for child processes and worker threads.
*/
const childProcessIntegration = core.defineIntegration((options = {}) => {
return {
name: INTEGRATION_NAME,
setup() {
diagnosticsChannel.channel('child_process').subscribe((event) => {
if (event && typeof event === 'object' && 'process' in event) {
captureChildProcessEvents(event.process , options);
}
});
diagnosticsChannel.channel('worker_threads').subscribe((event) => {
if (event && typeof event === 'object' && 'worker' in event) {
captureWorkerThreadEvents(event.worker , options);
}
});
},
};
});
function captureChildProcessEvents(child, options) {
let hasExited = false;
let data;
child
.on('spawn', () => {
// This is Sentry getting macOS OS context
if (child.spawnfile === '/usr/bin/sw_vers') {
hasExited = true;
return;
}
data = { spawnfile: child.spawnfile };
if (options.includeChildProcessArgs) {
data.spawnargs = child.spawnargs;
}
})
.on('exit', code => {
if (!hasExited) {
hasExited = true;
// Only log for non-zero exit codes
if (code !== null && code !== 0) {
core.addBreadcrumb({
category: 'child_process',
message: `Child process exited with code '${code}'`,
level: code === 0 ? 'info' : 'warning',
data,
});
}
}
})
.on('error', error => {
if (!hasExited) {
hasExited = true;
core.addBreadcrumb({
category: 'child_process',
message: `Child process errored with '${error.message}'`,
level: 'error',
data,
});
}
});
}
function captureWorkerThreadEvents(worker, options) {
let threadId;
worker
.on('online', () => {
threadId = worker.threadId;
})
.on('error', error => {
if (options.captureWorkerErrors !== false) {
core.captureException(error, {
mechanism: { type: 'auto.child_process.worker_thread', handled: false, data: { threadId: String(threadId) } },
});
} else {
core.addBreadcrumb({
category: 'worker_thread',
message: `Worker thread errored with '${error.message}'`,
level: 'error',
data: { threadId },
});
}
});
}
exports.childProcessIntegration = childProcessIntegration;
//# sourceMappingURL=childProcess.js.map