anyone else run into issues re: function serializa...
# typescript
anyone else run into issues re: function serialization and using a pulumi ComponentResource? i refactored a lambda/API gateway setup to be composed in a ComponentResource and now when the function is serialized, it omits all of the member functions required to do the job
the only function that was serialized was the one passed directly to
but all functions it referenced were not serialized
^ that's basically the constructor that assigns a member function to the Callback Function
i figured out a workaround; you've gotta create a service object with the functions you want to use in the callback, instantiate it, and then pass it to
as an arrow function w/ the service object instance caught in the closure
idk if that would be easy for others to figure out, took me a while
That’s interesting — I would’ve found this surprising, too. Glad you found a way through it. I wonder if there’s something about
specifically that got in the way somehow, because this, at least for me, seems to work:
and with a
, I also see
serialized into the Lambda:
… so I wonder what happened there. 🤔
yeah. also curious. it was using
, it was another member function of the instance
aha, so you saw something like this?
yes, exactly
nice, ok. seems like this is either a bug or something that needs to be documented — will report back!
Ended up filing this, as I think it may be a bug — or at least need better documentation!
yeah, i wonder if it's possible to serialize in that situation at all. i believe the "instance" or object created from the object prototype exists at the time that the function assignment occurs, but i'm not sure it's simply a matter of capturing everything in the closure and i'm not sure how you would make the serializer aware a particular closure was a "constructor" (since it's syntax sugar/ it's really just another function)