Skip to main content

Error Notifications Worker

Sends daily reports about work items that have permanently failed (exhausted all retries).

Included in Base Preset

Registered automatically by registerBasePlugins() / registerAllPlugins().

Registration​

import { pluginRegistry } from '@unchainedshop/core';
import { ErrorNotificationsPlugin } from '@unchainedshop/plugins/worker/error-notifications';

pluginRegistry.register(ErrorNotificationsPlugin);

Purpose​

The Error Notifications Worker helps you stay informed about system issues by:

  • Collecting permanently failed work items (no retries left) from the look-back window
  • Triggering a MESSAGE work item with the ERROR_REPORT template
  • Excluding its own failures to prevent notification loops

Auto-Scheduling​

Runs automatically every day at 03:00 (configured on registration) with secondsPassed: 86400 — a 24-hour look-back.

Manual Trigger​

You can also trigger a report manually:

mutation SendErrorReport {
addWork(
type: ERROR_NOTIFICATIONS
input: {
secondsPassed: 86400
}
) {
_id
status
}
}

Input Parameters​

ParameterTypeDefaultDescription
secondsPassedNumber60Seconds to look back (before the work item's scheduled time) for failed work items. The auto-scheduled run passes 86400.

The ERROR_REPORT Template​

The platform registers a default ERROR_REPORT template that emails a plain-text report. Configure it via environment variables:

VariableDefaultDescription
EMAIL_ERROR_REPORT_RECIPIENTsupport@unchained.localRecipient of the error report
EMAIL_FROMnoreply@unchained.localSender address
EMAIL_WEBSITE_NAMEUnchainedShop name used in the subject and body

To customize the report, re-register the template after startPlatform:

import { MessagingDirector } from '@unchainedshop/core';

MessagingDirector.registerTemplate('ERROR_REPORT', async ({ workItems }) => {
const summary = workItems.map(work =>
`- ${work.type}: ${work.error?.message || 'Unknown error'}`
).join('\n');

return [{
type: 'EMAIL',
input: {
to: 'admin@example.com',
subject: `[Unchained] ${workItems.length} failed work items`,
text: `The following work items have permanently failed:\n\n${summary}`,
},
}];
});

Result​

{
"forked": "message-work-id"
}

forked is the ID of the created MESSAGE work item. If no failed work items are found, the result will be empty and no message is sent.

Adapter Details​

PropertyValue
Keyshop.unchained.worker.error-notifications
TypeERROR_NOTIFICATIONS
Auto-ScheduleDaily at 03:00
Retries0
Sourceworker/error-notifications