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

Import incorrectly identified as remote module, fails to run #1170

Closed
acceleratxr opened this issue Sep 21, 2019 · 4 comments
Closed

Import incorrectly identified as remote module, fails to run #1170

acceleratxr opened this issue Sep 21, 2019 · 4 comments

Comments

@acceleratxr
Copy link

My script uses a locally installed module of the name @acceleratxr/utilities as is imported like so

import utils from "@acceleratxr/utilities";

When running my test I get the following warning and error.

WARN[0000] A url was resolved but it didn't have scheme. This will be deprecated in the future and all remote modules will need to explicitly use `https` as scheme  url=//@acceleratxr/utilities 
ERRO[0005] GoError: The moduleSpecifier "@acceleratxr/utilities" couldn't be retrieved from the resolved url "https://@acceleratxr/utilities". Error : "Get https://@acceleratxr/utilities: dial tcp: lookup acceleratxr: no such host"

It appears that k6 is incorrectly identifying this module as a remote URL when in fact it is a locally installed module. This shouldn't happen.

@acceleratxr
Copy link
Author

OK so I found the documentation that says you can't use Node.js modules directly. This is very poorly documented in the initial guides and tutorials. I would suggest putting a big warning in the Getting Started page to avoid confusion as there is currently no mention of this anywhere until much later in the docs.

@cuonglm cuonglm reopened this Sep 24, 2019
@cuonglm cuonglm added docs enhancement evaluation needed proposal needs to be validated or tested before fully implementing it in k6 labels Sep 24, 2019
@na-- na-- added ux and removed evaluation needed proposal needs to be validated or tested before fully implementing it in k6 labels Jan 15, 2020
@na--
Copy link
Member

na-- commented Jan 15, 2020

We need to actually improve the UX of the error messages we display to users when they import or try to run a non-existent file. Right now, running k6 run nonexistent-file.js would result in the following confusing warning+error combo:

WARN[0000] A url was resolved but it didn't have scheme. This will be deprecated in the future and all remote modules will need to explicitly use `https` as scheme  url=//nonexistent-file.js
ERRO[0000] The moduleSpecifier "nonexistent-file.js" couldn't be retrieved from the resolved url "https://nonexistent-file.js". Error : "Get https://nonexistent-file.js: dial tcp: lookup nonexistent-file.js: no such host" 

The user doesn't know that k6 first tried to load the file locally, and because it didn't find it, tried to treat it as an URL. We do that to be backwards compatible with the functionality of being able to execute k6 run mysite.com/some.js... We're slowly trying to deprecate this by always requiring schemas in URLs (i.e. k6 run https://mysite.com/some.js), but we haven't fully deprecated it yet, thus the first warning. Anyway, the k6 error from v0.24.0 was more informative, so we should go back to something like it:

ERRO[0000] The file "nonexistent-file.js" couldn't be found on local disk, and trying to retrieve it from https://nonexistent-file.js failed as well. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see https://docs.k6.io/v1.0/docs/modules#section-using-local-modules-with-docker. 

@mstoykov
Copy link
Contributor

after 0.27.0 the message will be

image

which I think is sufficient to close this?

@mstoykov mstoykov added this to the v0.27.0 milestone Jun 30, 2020
@na--
Copy link
Member

na-- commented Jul 6, 2020

Closing this, since the just-merged #1007 added the improved message in the screenshot above

@na-- na-- closed this as completed Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants