How to implement process uncaughtException on a Shopify Custom App?

Topic summary

A developer is struggling to implement global error handlers (uncaughtException and unhandledRejection) in a Shopify custom app built with Remix.

Problem:

  • Attempted to add error handlers in multiple locations:
    • entry.server.jsx
    • shopify.server.js
    • Individual routes
  • Handlers fail to catch intentionally thrown errors without try-catch blocks

Code snippet provided:
The developer shared reversed/obfuscated code showing standard Node.js process event listeners for:

  • process.on('uncaughtException') - logs error and exits process
  • process.on('unhandledRejection') - logs rejection reason

Current status:

  • Question remains unanswered
  • Seeking guidance on proper placement of these handlers within Remix-based Shopify app architecture
Summarized with AI on November 15. AI used: claude-sonnet-4-5-20250929.

I’m trying to add process “uncaughtException” and “unhandledRejection” on my Shopify App, but I’m having hardtime on it.
I tried adding it on the entry.server.jsx, shopify.server.js and on my routes but it seems not working if I purposely throw an error without catch.
Where should I possibly add this on my app? Currently my app was made using Remix template.

process.on('uncaughtException', (error) => {
    console.error('Uncaught Exception:', error);
    // Handle the error or perform cleanup here.
    process.exit(1);
})
.on('unhandledRejection', (reason, promise) => {
    console.error('Unhandled Promise Rejection:', reason);
    // Handle or log the rejection reason here.
});