This message was deleted.
# general
s
This message was deleted.
b
when I try to create new Random() like that: const c = new Random('name')
Copy code
Previewing update (dev):
     Type                 Name       Plan     Info
     pulumi:pulumi:Stack  infra-dev           1 error; 26 messages

Diagnostics:
  pulumi:pulumi:Stack (infra-dev):
    Error: Error serializing '() => provider': index.js(19,37)
    '() => provider': index.js(19,37): captured
      variable 'provider' which indirectly referenced
        function 'create': index.ts(66,10): which captured
          variable 'crypto' which indirectly referenced
            function 'randomBytes': random.js(51,20): which referenced
              function 'assertSize': random.js(35,19): which referenced
                function 'validateNumber': which captured
                  'ERR_INVALID_ARG_TYPE', a function defined at
                    function 'NodeError': which referenced
                      function 'getMessage': which captured
                        variable 'messages' which indirectly referenced
                          function 'get': which could not be serialized because
                            it was a native code function.
    Function code:
      function get() { [native code] }
        at throwSerializationError (/home/az/learn/pulumi/infra/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:458:11)
        at /home/az/learn/pulumi/infra/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:211:21
        at Generator.next (<anonymous>)
        at /home/az/learn/pulumi/infra/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/home/az/learn/pulumi/infra/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:17:12)
        at serializeWorkerAsync (/home/az/learn/pulumi/infra/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:199:20)
        at /home/az/learn/pulumi/infra/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:177:30
        at Generator.next (<anonymous>)
        at fulfilled (/home/az/learn/pulumi/infra/node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:18:58)

    error: Error serializing '() => provider': index.js(19,37)

    '() => provider': index.js(19,37): captured
      variable 'provider' which indirectly referenced
        function 'create': index.ts(66,10): which captured
          variable 'crypto' which indirectly referenced
            function 'randomBytes': random.js(51,20): which referenced
              function 'assertSize': random.js(35,19): which referenced
                function 'validateNumber': which captured
                  'ERR_INVALID_ARG_TYPE', a function defined at
                    function 'NodeError': which referenced
                      function 'getMessage': which captured
                        variable 'messages' which indirectly referenced
                          function 'get': which could not be serialized because
                            it was a native code function.

    Function code:
      function get() { [native code] }
b
Hi Eugene, you're following the javascript examples right? Can you post the code you have so far?
b
sure, it's just the code from the example plus the line I mentioned above
here is the whole program:
Copy code
import * as pulumi from '@pulumi/pulumi'
import * as crypto from 'crypto'

const randomprovider: pulumi.dynamic.ResourceProvider = {
  async create(inputs) {
    return { id: crypto.randomBytes(16).toString('hex'), outs: {} }
  },
}

export class Random extends pulumi.dynamic.Resource {
  constructor(name: string, opts?: pulumi.CustomResourceOptions) {
    super(randomprovider, name, {}, opts)
  }
}

const r = new Random('name')
I am following typescript examples