Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [22.x]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 24.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [22.x]

steps:
- name: Checkout code
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ This should cause the adapter to crash and the exception to be shown in the sent
-->

## Changelog
### __WORK IN PROGRESS__
* (Apollon77) Update Sentry SDK to prevent issues in current Node.js versions

### 2.0.4 (2024-06-01)
* (foxriver76) work with plugin base v2
* (foxriver76) ported to TypeScript to provide improved type support
Expand Down
175 changes: 87 additions & 88 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,105 +120,104 @@ class SentryPlugin extends plugin_base_1.PluginBase {
dsn: pluginConfig.dsn,
integrations: [new SentryIntegrations.Dedupe()]
});
this.Sentry.configureScope(scope => {
if (this.parentIoPackage && this.parentIoPackage.common) {
scope.setTag('version', this.parentIoPackage.common.installedVersion || this.parentIoPackage.common.version);
if (this.parentIoPackage.common.installedFrom) {
scope.setTag('installedFrom', this.parentIoPackage.common.installedFrom);
}
else {
scope.setTag('installedFrom', this.parentIoPackage.common.installedVersion || this.parentIoPackage.common.version);
}
if (this.settings && this.settings.controllerVersion) {
scope.setTag('jsControllerVersion', this.settings.controllerVersion);
}
scope.setTag('osPlatform', process.platform);
scope.setTag('nodejsVersion', process.version);
try {
scope.setTag('plugin-sentry', require('./package.json').version);
}
catch {
// ignore
const scope = this.Sentry.getCurrentScope();
if (this.parentIoPackage && this.parentIoPackage.common) {
scope.setTag('version', this.parentIoPackage.common.installedVersion || this.parentIoPackage.common.version);
if (this.parentIoPackage.common.installedFrom) {
scope.setTag('installedFrom', this.parentIoPackage.common.installedFrom);
}
else {
scope.setTag('installedFrom', this.parentIoPackage.common.installedVersion || this.parentIoPackage.common.version);
}
if (this.settings && this.settings.controllerVersion) {
scope.setTag('jsControllerVersion', this.settings.controllerVersion);
}
scope.setTag('osPlatform', process.platform);
scope.setTag('nodejsVersion', process.version);
try {
scope.setTag('plugin-sentry', require('./package.json').version);
}
catch {
// ignore
}
if (this.iobrokerConfig) {
if (this.iobrokerConfig.objects && this.iobrokerConfig.objects.type) {
scope.setTag('objectDBType', this.iobrokerConfig.objects.type);
}
if (this.iobrokerConfig) {
if (this.iobrokerConfig.objects && this.iobrokerConfig.objects.type) {
scope.setTag('objectDBType', this.iobrokerConfig.objects.type);
}
if (this.iobrokerConfig.states && this.iobrokerConfig.states.type) {
scope.setTag('statesDBType', this.iobrokerConfig.states.type);
}
if (this.iobrokerConfig.states && this.iobrokerConfig.states.type) {
scope.setTag('statesDBType', this.iobrokerConfig.states.type);
}
}
if (uuid) {
scope.setUser({
id: uuid
});
}
if (uuid) {
scope.setUser({
id: uuid
});
}
scope.addEventProcessor((event, hint) => {
if (!this.isActive) {
return;
}
scope.addEventProcessor((event, hint) => {
if (!this.isActive) {
return;
// Try to filter out some events
if (event.exception && event.exception.values && event.exception.values[0]) {
const eventData = event.exception.values[0];
// if the error type is one from the blacklist, we ignore this error
if (eventData.type && sentryErrorBlacklist.includes(eventData.type)) {
return null;
}
// Try to filter out some events
if (event.exception && event.exception.values && event.exception.values[0]) {
const eventData = event.exception.values[0];
// if the error type is one from the blacklist, we ignore this error
if (eventData.type && sentryErrorBlacklist.includes(eventData.type)) {
return null;
}
const originalException = hint.originalException;
// ignore EROFS, ENOSPC and such errors always
const errorText = originalException && originalException.code
? originalException.code.toString()
: originalException && originalException.message
? originalException.message.toString()
: originalException;
if (typeof errorText === 'string' &&
(errorText.includes('EROFS') || // Read only FS
errorText.includes('ENOSPC') || // No disk space available
errorText.includes('ENOMEM') || // No memory (RAM) available
errorText.includes('EIO') || // I/O error
errorText.includes('ENXIO') || // I/O error
errorText.includes('EMFILE') || // too many open files
errorText.includes('ENFILE') || // file table overflow
errorText.includes('EBADF')) // Bad file descriptor
) {
const originalException = hint.originalException;
// ignore EROFS, ENOSPC and such errors always
const errorText = originalException && originalException.code
? originalException.code.toString()
: originalException && originalException.message
? originalException.message.toString()
: originalException;
if (typeof errorText === 'string' &&
(errorText.includes('EROFS') || // Read only FS
errorText.includes('ENOSPC') || // No disk space available
errorText.includes('ENOMEM') || // No memory (RAM) available
errorText.includes('EIO') || // I/O error
errorText.includes('ENXIO') || // I/O error
errorText.includes('EMFILE') || // too many open files
errorText.includes('ENFILE') || // file table overflow
errorText.includes('EBADF')) // Bad file descriptor
) {
return null;
}
if (eventData.stacktrace &&
eventData.stacktrace.frames &&
Array.isArray(eventData.stacktrace.frames) &&
eventData.stacktrace.frames.length) {
// if the last exception frame is from a nodejs internal method, we ignore this error
if (eventData.stacktrace.frames[eventData.stacktrace.frames.length - 1].filename &&
(eventData.stacktrace.frames[eventData.stacktrace.frames.length - 1].filename.startsWith('internal/') ||
eventData.stacktrace.frames[eventData.stacktrace.frames.length - 1].filename.startsWith('Module.'))) {
return null;
}
if (eventData.stacktrace &&
eventData.stacktrace.frames &&
Array.isArray(eventData.stacktrace.frames) &&
eventData.stacktrace.frames.length) {
// if the last exception frame is from a nodejs internal method, we ignore this error
if (eventData.stacktrace.frames[eventData.stacktrace.frames.length - 1].filename &&
(eventData.stacktrace.frames[eventData.stacktrace.frames.length - 1].filename.startsWith('internal/') ||
eventData.stacktrace.frames[eventData.stacktrace.frames.length - 1].filename.startsWith('Module.'))) {
return null;
// Check if any entry is whitelisted from pathWhitelist
const whitelisted = eventData.stacktrace.frames.find(frame => {
if (frame.function && frame.function.startsWith('Module.')) {
return false;
}
if (frame.filename && frame.filename.startsWith('internal/')) {
return false;
}
if (frame.filename &&
!sentryPathWhitelist.find(path => path && path.length && frame.filename.includes(path))) {
return false;
}
// Check if any entry is whitelisted from pathWhitelist
const whitelisted = eventData.stacktrace.frames.find(frame => {
if (frame.function && frame.function.startsWith('Module.')) {
return false;
}
if (frame.filename && frame.filename.startsWith('internal/')) {
return false;
}
if (frame.filename &&
!sentryPathWhitelist.find(path => path && path.length && frame.filename.includes(path))) {
return false;
}
if (frame.filename &&
sentryPathBlacklist.find(path => path && path.length && frame.filename.includes(path))) {
return false;
}
return true;
});
if (!whitelisted) {
return null;
if (frame.filename &&
sentryPathBlacklist.find(path => path && path.length && frame.filename.includes(path))) {
return false;
}
return true;
});
if (!whitelisted) {
return null;
}
}
return event;
});
}
return event;
});
}
/**
Expand Down
Loading
Loading