Skip to content

Compatibility of the crash handler with serverless #57

@GeoffThorpeFT

Description

@GeoffThorpeFT

When we moved to node 18 we used the example to apply very similar code to a collection of our serverless apps.
However, one of those apps - the Problem Hub API - is now logging compatibility errors to splunk.

For example:

app: { [[-]](https://financialtimes.splunkcloud.com/en-GB/app/search/search?q=search%20index%3Daws_cloudwatch%20source%3D%2Faws%2Flambda%2Fproblem-hub-api*%20level%3Derror%20%20event%3DHANDLED_ERROR&earliest=1696575600.000&latest=1696577400&sid=1696602769.846655&display.page.search.mode=verbose&dispatch.sample_ratio=1&workload_pool=standard_perf#)
     commit: null
     name: problem-hub-api
     nodeVersion: 18.17.1
     processType: problem-hub-api-prod-deleteMessage
     region: eu-west-1
     releaseDate: null
   }
   error: { [[-]](https://financialtimes.splunkcloud.com/en-GB/app/search/search?q=search%20index%3Daws_cloudwatch%20source%3D%2Faws%2Flambda%2Fproblem-hub-api*%20level%3Derror%20%20event%3DHANDLED_ERROR&earliest=1696575600.000&latest=1696577400&sid=1696602769.846655&display.page.search.mode=verbose&dispatch.sample_ratio=1&workload_pool=standard_perf#)
     cause: null
     code: CRASH_HANDLER_NOT_REGISTERED
     data: { [[-]](https://financialtimes.splunkcloud.com/en-GB/app/search/search?q=search%20index%3Daws_cloudwatch%20source%3D%2Faws%2Flambda%2Fproblem-hub-api*%20level%3Derror%20%20event%3DHANDLED_ERROR&earliest=1696575600.000&latest=1696577400&sid=1696602769.846655&display.page.search.mode=verbose&dispatch.sample_ratio=1&workload_pool=standard_perf#)
     }
     isOperational: false
     message: Crash Handler cannot be used alongside other uncaughtException or unhandledRejection handlers
     name: Error
     relatesToSystems: [ [[-]](https://financialtimes.splunkcloud.com/en-GB/app/search/search?q=search%20index%3Daws_cloudwatch%20source%3D%2Faws%2Flambda%2Fproblem-hub-api*%20level%3Derror%20%20event%3DHANDLED_ERROR&earliest=1696575600.000&latest=1696577400&sid=1696602769.846655&display.page.search.mode=verbose&dispatch.sample_ratio=1&workload_pool=standard_perf#)
     ]
     stack: Error: Crash Handler cannot be used alongside other uncaughtException or unhandledRejection handlers
    at registerCrashHandler (/var/task/node_modules/@dotcom-reliability-kit/crash-handler/lib/index.js:35:5)
    at Object.<anonymous> (/var/task/src/handlers/deleteMessage.js:13:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at _tryRequireFile (file:///var/runtime/index.mjs:976:37)
    at _tryRequire (file:///var/runtime/index.mjs:1026:25)
     statusCode: null
   }
   event: HANDLED_ERROR
   level: error
   message: Error: Crash Handler cannot be used alongside other uncaughtException or unhandledRejection handlers
   time: 1696577091181
}

Here is the PR we used to require and register the crashHandler across all the handlers in the app: https://github.com/Financial-Times/problem-hub-api/pull/329/files#diff-27e55b3729e43add040290800f8a23b3cfe1838eab31f9c23dc831a391c516ee

Any ideas what we may have done wrong?

It is because the app has many handlers?
Should we register inside each serverless handler instead just outside?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions