Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Object.setPrototypeOf() unavailable #43

Closed
bookmoons opened this issue Oct 10, 2019 · 11 comments · Fixed by #44
Closed

Object.setPrototypeOf() unavailable #43

bookmoons opened this issue Oct 10, 2019 · 11 comments · Fixed by #44

Comments

@bookmoons
Copy link
Contributor

Some dependencies modify prototypes. Since the k6 JavaScript environment doesn't provide Object.setPrototypeOf(), loading fails for these libraries.

Find a solution.

@bookmoons
Copy link
Contributor Author

Ran a bundling of each dependency to narrow it down. These libraries show the issue:

  • cheerio
  • xml2js
  • aws4

All the rest are fine.

@bookmoons
Copy link
Contributor Author

A little testing shows this seems to work with a polyfill. xml2js loads and parses successfully.

Going to polish this into a patch soon.

@danni-popova
Copy link

I can still see the issue happening. When trying to run the converted Postman collection, I get this:

TypeError: Object has no member 'setPrototypeOf' at file:///home/danni/Test/k6/libs/aws4.js:8054:22(344)

@robingustafsson
Copy link
Member

@danni-popova Are you seeing this in a version of the converter based on master branch? I'm asking as there's unfortunately not yet been an official release published on npm of the converter including this fix. I was waiting on some other changes to make it into master before releasing a new version, but as those changes will take longer than thought I'll push a release later today.

@danni-popova
Copy link

Great! Looking forward to the release

@robingustafsson
Copy link
Member

@danni-popova A new release, v0.3.1, has now been published to npm. Let us know if your issue persists after updating.

@danni-popova
Copy link

The result now is that I always get a message saying: Get : unsupported protocol scheme \"\. Tried on multiple requests that otherwise work in Postman.

@bookmoons
Copy link
Contributor Author

Hi @danni-popova. I could have a look at this. Is the collection something you could post?

@danni-popova
Copy link

// Auto-generated by the Load Impact converter

import "./libs/spo-gpo.js";
import "./libs/shim/core.js";
import URI from "./libs/urijs.js";
import aws4 from "./libs/aws4.js";

export let options = { maxRedirects: 4 };

const Request = Symbol.for("request");
postman[Symbol.for("initial")]({
  options
});

export default function() {
  postman[Request]({
    name: "discovery",
    id: "aa538977-373a-463b-937a-f371ddd71968",
    method: "GET",
    address:
      "https://{replaced_url}",
    auth(config, Var) {
      const address = new URI(config.address);
      const options = {
        method: "GET",
        protocol: address.protocol(),
        hostname: address.hostname(),
        port: address.port(),
        path: address.path() + address.search(),
        region: "eu-west-1",
        service: "cf"
      };
      const credential = {
        accessKeyId: "{replaced_access_key}",
        secretAccessKey: "{replaced_secret_key}"
      };
      const signed = aws4.sign(options, credential);
      const [path, query] = signed.path.split("?");
      config.address = new URI()
        .protocol(address.protocol())
        .hostname(signed.hostname)
        .path(path)
        .query(query)
        .toString();
      Object.assign(config.headers, signed.headers);
    }
  });
}

Here's the generated file. I've manually replaced the values in it, otherwise they are written directly in the script and not actually from an environment. The collection runs without a problem in Postman.

@bookmoons
Copy link
Contributor Author

Thanks @danni-popova. I confirm I see the same error. Will investigate. Opened #46 to track this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants