Giter Site home page Giter Site logo

Comments (7)

nicholasgriffintn avatar nicholasgriffintn commented on September 22, 2024

I don't have a clue what you're talking about honestly, please provide more detail with some sort of reproducible example, without that, we can't help you.

from sqs-consumer.

elmeister avatar elmeister commented on September 22, 2024

Ok, so here's the zod library, which is pretty popular

Here is their ZodError implementation

For the minimal reproducible example, here's the error class with the sane idea as in ZodError:

class CustomError extends Error {
  issues: string[]

  constructor(issues: string[]) {
    super()

    this.issues = issues
  }

  get message() {
    return this.issues.join(', ')
  }
}

Now if within the handleMessage() the error above will be thrown

throw new CustomError(['issue1', 'issue2'])

It will fail here
In these consumer.ts lines of code

err.message =
  err instanceof TimeoutError
    ? `Message handler timed out after ${this.handleMessageTimeout}ms: Operation timed out.`
    : `Unexpected message handler failure: ${err.message}`;

So instead of "Unexpected message handler" we will receive only the error from consumer.ts

TypeError: Cannot set property message of [object Object] which has only a getter

from sqs-consumer.

nicholasgriffintn avatar nicholasgriffintn commented on September 22, 2024

Ahh I see so you're throwing a zod error and that is causing sqs-consumer to error.

Not an issue with sqs consumer itself but with the reformatting of the error from zod that was thrown, as sqs consumer is changing the property 'message' which you have pre defined as a get.

from sqs-consumer.

elmeister avatar elmeister commented on September 22, 2024

Zod package is commonly used to validate and add types to unknown data, which perfectly fits for SQS message body, and Zod throws its own error with getter for message, when data was not valid.
The issue is manageable by adding try/catch wrapper for the handleMessage()callback content.

from sqs-consumer.

nicholasgriffintn avatar nicholasgriffintn commented on September 22, 2024

Sorry not sure I explained well enough, but basically, I know what zod is, the issue here is that the error sent has a property that is only a get, which means that sqs-consumer is unable to edit the message property itself.

This removes its ability to adjust the message property and thus offer its own error functionality, you're basically overwriting that ability with this implementation.

The error being outputted is correct and is actually on your app's side, and isn't a bug with sqs-consumer itself.

from sqs-consumer.

elmeister avatar elmeister commented on September 22, 2024

I do not overwrite that ability in my app, it's how zod's parse() method works.
But anyways, closing this.

from sqs-consumer.

github-actions avatar github-actions commented on September 22, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

from sqs-consumer.

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.