Comments (2)
I'm adding some follow up to this since its been a few weeks without any response.
I've been through the documentation on logging:
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.
from hapi.
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.
from hapi.
Related Issues (20)
- Buffer response with binary status validation always throws 500 HOT 1
- Node sockets timeout after 2 minutes by default HOT 1
- Open-source latest v16 HOT 1
- Cannot bind to Fully qualified domain name (FQDN) HOT 2
- Why does the credentials CORS options accept only false? HOT 4
- [TS] Defining the handler and the return type
- Need help in migrating Hapi application to v20.0.1 HOT 1
- Cookie Partition support
- No response when payload is large HOT 2
- Support lambda direct requests over HTTPS HOT 1
- Catbox catbox-memory throws an error but it is not handled properly HOT 1
- Request object does not have query object populated HOT 1
- Handling Expect: 100-continue HOT 4
- Build issues HOT 3
- HTTP_METHODS_PARTIAL_LOWERCASE is missing `head` HOT 1
- hapi jwt package not able to recognize comma separated cookie as JWT HOT 3
- Nextjs is not supported as a server HOT 2
- multipart validation doesn't comply with new fetch api
- Missing maxParts type in route.d.ts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hapi.