Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having Invalid Regular Expression when using url lib #1834

Closed
wsee911 opened this issue Feb 2, 2021 · 6 comments
Closed

Having Invalid Regular Expression when using url lib #1834

wsee911 opened this issue Feb 2, 2021 · 6 comments
Labels

Comments

@wsee911
Copy link

wsee911 commented Feb 2, 2021

I am getting an Invalid regular expression (re2) when using import "url". I have gone through and isolated that this lib when imported is giving issues.

Environment

  • k6 version: 0.29
  • OS and version: MacOS 10.15.7
  • NodeJS: 12.16.3

Expected Behavior

The test should build normally with using the url lib

Actual Behavior

It is throwing invalid regular expression when k6 is building.
image
Screenshot above on the error.

Steps to Reproduce the Problem

May try using the below code to run the load test.

import * as k6Options from "k6/options";
import "url";

export const options: Partial<k6Options.Options> = {
	scenarios: {
		createEventLoadTest: {
			executor: 'per-vu-iterations',
			vus: 2,
			iterations: 10,
			exec: "loadTest",
		},
	},
};

let count = 0;

export function setup() {
}

export function loadTest() {
	console.log("running");
}

export function teardown() {
}
@wsee911 wsee911 added the bug label Feb 2, 2021
@na--
Copy link
Member

na-- commented Feb 2, 2021

How exactly have you bundled your script before you ran it with k6? browserify, webpack? please give us the complete steps we can use to reproduce this behavior...

Also, you might try to upgrade to k6 v0.30.0, it has some changes in the JS runtime we use that are related to regular expressions, so it might fix your problem.

@imiric
Copy link
Contributor

imiric commented Feb 2, 2021

Isn't the "invalid repeat count" error a limitation of Go's regexp package? golang/go#7252

There's not much we can do in that case.

@na--
Copy link
Member

na-- commented Feb 2, 2021

Yeah, seems so, and yes, it's not something we can change in k6 or even goja... 😞 Sorry, @wsee911, I'm not sure where {1,8856} comes from, probably something auto-generated from babel/browserify/webpack/etc., since I doubt such a group count would make sense in a normal program...

@wsee911
Copy link
Author

wsee911 commented Feb 3, 2021

I see, but to reply to @na-- question, I am using webpack and ts-loader to bundle the script.

@na--
Copy link
Member

na-- commented Feb 3, 2021

@wsee911, can you post a complete example reproduces this issue in a github gist? Both a simple k6 TS script and a webpack config that result in a faulty script? I tried using the snippet you provided with https://github.com/k6io/template-typescript and that didn't result in the error.

I'm asking, since it might be worth tracking down which JS library is responsible for the unusual regex and submitting a small PR to fix it, if it's simple.

@wsee911
Copy link
Author

wsee911 commented Feb 5, 2021

Hi so been searching around and realise this was the issue that has been plaguing me this few days. As webpack was having trouble bundling it. Gonna close this bug as its not a k6 issue.
defunctzombie/node-url#37

@wsee911 wsee911 closed this as completed Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants