Git Product home page Git Product logo

Comments (2)

geuis avatar geuis commented on May 25, 2024

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.

kanongil avatar kanongil commented on May 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.