You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ran into an issue where errors generated by application code are having their errors suppressed run in debug mode locally.
I have a route that is generating an error. When running locally, I'm just getting Boom internal server errors and not getting the actual error log messages.
I have the route wrapped in a try/catch and I can console.error the full logs in the catch, but I feel like there should be a global routes setting somewhere like debug that will just dump all errors like this to the console without needing special handling each time.
Note that failAction below does not get triggered either.
Here's a sample route for some Stripe webhooks I'm working on:
server.route({
path: '/api/v1/webhooks',
method: 'post',
options: {
auth: false,
payload: {
parse: false
}
},
handler: async (req, h) => {
let sig;
let stripeEvent;
try {
sig = req.headers['stripe-signature'];
stripeEvent = stripeClient.webhooks.constructEvent(req.payload.toString(), sig, process.env.STRIPE_WEBHOOK_ENDPOINT_SECRET);
} catch (err) {
// this logs to the console.
console.log('webhook signature verification failed:', err.message);
return h.response().code(400);
}
try {
const { type: eventType } = stripeEvent;
switch (eventType) {
// this contains some code that intentionally causes an error when I run "stripe trigger customer.subscription.deleted"
break;
}
default:
console.log(`Unhandled webhook: ${eventType}`);
break;
}
return h.response().code(200);
} catch (err) {
// not seen
process.stdout.write(err);
// not seen
console.error(`Webhook eventType: ${eventType}`, err);
// not seen
server.log('error', `Webhook eventType: ${eventType}`);
// not seen
req.log('error', `Webhook eventType: ${eventType}`);
throw err;
}
All I get in the terminal is
Debug: handler, error
{"code":"ERR_UNKNOWN_ENCODING","isBoom":true,"isServer":true,"data":null,"output":{"statusCode":500,"payload":{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"},"headers":{}},"isDeveloperError":true}
2023-12-09 23:31:40 <-- [500] POST http://localhost:2000/api/v1/webhooks [evt_1OLhUFCKVl5kfDhd9LsStTaA]
I'm probably missing something, but I've been through the docs and I think I have this configured correctly. However, the callstack for the errors are being hidden.
You are probably not seeing the stack trace since you are using a not yet supported node runtime (v21.x), where they can go missing due to a change described in hapijs/boom#302.
For the current version of hapi I would advise you to stay on node v18 for the time being.
Runtime
node
Runtime version
21.1
Module version
huh?
Used with
hapi 21.3.2
Any other relevant information
No response
How can we help?
Ran into an issue where errors generated by application code are having their errors suppressed run in debug mode locally.
I have a route that is generating an error. When running locally, I'm just getting Boom internal server errors and not getting the actual error log messages.
I have the route wrapped in a try/catch and I can
console.error
the full logs in the catch, but I feel like there should be a global routes setting somewhere likedebug
that will just dump all errors like this to the console without needing special handling each time.Note that
failAction
below does not get triggered either.I've read up on
debug
https://hapi.dev/api/?v=21.3.2#-serveroptionsdebug though maybe I'm missing something?My current server config:
The text was updated successfully, but these errors were encountered: