Skip to content

TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property '$response' which is either non-existent or configurable in the proxy target #272

@jan-osch

Description

@jan-osch

Node: v12.16.0
vm2: 3.9.0
aws-sdk: 2.642.0

const { NodeVM } = require('vm2');

const vm = new NodeVM({
  console: 'inherit',
  require: {
    external: {
      modules: [
        'aws-sdk',
      ],
    },
  },
});

const code = `
  const AWS = require('aws-sdk');

  const s3 = new AWS.S3({
    apiVersion: '2006-03-01'
  });

  s3.listBuckets()
    .promise()
    .then(
      data => console.log(JSON.stringify(data))
    );
`;

vm.run(code, 'somescript.js');

I am getting an exception TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property '$response' which is either non-existent or configurable in the proxy target

I think the issue is that aws-sdk adds a new non-enumerable property $response to a Proxy
https://github.com/aws/aws-sdk-js/blob/master/lib/request.js#L785.

I found a mention about this error in the contextify implementation
https://github.com/patriksimek/vm2/blob/master/lib/contextify.js#L283

The error itself is thrown in fnc.apply https://github.com/patriksimek/vm2/blob/master/lib/contextify.js#L179

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions