bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

[Bug]: job.data does not return the typed object.

Open rcfrias opened this issue 10 months ago • 2 comments

Version

v.5.7.4

Platform

NodeJS

What happened?

After setting up the handlers, I realize the job.data arrives untyped. This objects are instantiated from classes, so private members become public and functions undefined.

How to reproduce.

add a job with a custom object.

Relevant log output

job.data.getTimestamp is not a function

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

rcfrias avatar Apr 23 '24 19:04 rcfrias

I solved it temporally with a static variable to re-instantiate the object, although this misses the entire point of using . *I really wish there would be a workaround for this. (nothing to find at the docs) TypeScript: static serializeMessage(unserializedMessage: any): Message { return new Message( unserializedMessage.token, unserializedMessage.emitter_name, unserializedMessage.msg, unserializedMessage.delay, unserializedMessage.timestamp, unserializedMessage.attachments, ); }

rcfrias avatar Apr 23 '24 20:04 rcfrias

I don't think there is an issue here, can you provide specific typescript code so that we can understand what you mean?

manast avatar Apr 23 '24 20:04 manast