https://pulumi.com logo
#typescript
Title
# typescript
m

many-salesmen-89069

09/24/2021, 4:11 PM
Hi, I’m trying to implement a custom dynamic provider to upload files to S3. I’m currently stuck with this error:
Copy code
error: Error serializing '() => provider': index.js(28,47)

    '() => provider': index.js(28,47): captured
      variable 'provider' which indirectly referenced
        function 'S3UploadResourceProvider': s3Upload.ts(77,15): which referenced
          function 'create': s3Upload.ts(138,10): which referenced
            function 'uploadDirectoryToS3': s3Upload.ts(58,28): which referenced
              function 'getFiles': s3Upload.ts(28,17): which captured
                variable 'promises_1' which indirectly referenced
                  function 'readdir': which referenced
                    function 'getOptions': which captured
                      'ERR_INVALID_ARG_TYPE', a function defined at
                        function 'NodeError': which referenced
                          function 'isErrorStackTraceLimitWritable': which captured
                            'ObjectGetOwnPropertyDescriptor', a function defined at
                              function 'getOwnPropertyDescriptor': which could not be serialized because
                                it was a native code function.

    Function code:
      function getOwnPropertyDescriptor() { [native code] }
Would appreciate any ideas on how to work around this 🙂
b

billowy-army-68599

09/24/2021, 4:29 PM
hey there, could you share your code?
also, are you aware of the bucket object resource? 😄
m

many-salesmen-89069

09/24/2021, 4:36 PM
hey, thanks for looking into it! attaching the relevant code. the intention is to make atomic deploys possible with cloudfront + s3, so i can’t use the bucket object resource, bc that’ll delete the old files during deployment. the solution i came up with here is this custom dynamic resource that just uploads files to a prefix on s3 and i set the prefix as the origin path in cloudfront. it never deletes or updates files.
node version 16.9.1 btw
b

billowy-army-68599

09/24/2021, 4:38 PM
hmm I don't see anything at first glance I'm afraid, i'll try get someone smarter to have a look
m

many-salesmen-89069

09/24/2021, 4:38 PM
thanks! i’ll be off for the weekend now — back on Tuesday
c

curved-pharmacist-41509

09/25/2021, 4:05 AM
We have a library which does this https://github.com/sevenwestmedia-labs/pulumi-components/tree/main/libs/throw-files-in-s3 It works a bit differently but you can use it as a reference
m

many-salesmen-89069

09/28/2021, 9:37 AM
Thanks @curved-pharmacist-41509 your code gave me an idea to work around the issue: turns out that replacing promisifed readdir with the sync version makes it run. @billowy-army-68599 I’ve added a reproducible bug report here: https://github.com/pulumi/pulumi/issues/8090
8 Views