Skip to content

Commit

Permalink
feat(locksmith): better fatal error handling with a logging statement
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Mar 26, 2024
1 parent 0375dba commit 7131390
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion locksmith/src/controllers/purchaseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ export class PurchaseController {
)
logger.info(`Subscription updated for id: ${subscription?.id}`)
} catch (error) {
console.log(error)
if (response.headersSent) {
return
}
Expand Down
2 changes: 0 additions & 2 deletions locksmith/src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ export const retrieveEncryptedPrivatekey = async (
const result = await ethers.Wallet.createRandom().encrypt(
(Math.random() + 1).toString(36)
)
console.log(result)

return res.json({
passwordEncryptedPrivateKey: result,
})
Expand Down
2 changes: 1 addition & 1 deletion locksmith/src/fulfillment/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default class Dispatcher {
new Promise(
(resolve) =>
(timeout = setTimeout(() => {
console.log(
logger.error(
`Timeout while retrieving balance on network ${network.name} (${network.id})`
)
resolve(0)
Expand Down
7 changes: 7 additions & 0 deletions locksmith/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import logger from './logger'

logger.info('Starting Locksmith...')

process.on('uncaughtException', function (error, origin) {
logger.error('Fatal error:', origin)
logger.error(error.toString())
logger.error(error.stack)
process.exit(1)
})

const port = process.env.PORT || 8080

// in prod, we start immediately
Expand Down

0 comments on commit 7131390

Please sign in to comment.