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

Interop from ClojureScript doesn't seem to work since v0.53 #4050

Open
1 of 2 tasks
trueneu opened this issue Nov 11, 2024 · 5 comments
Open
1 of 2 tasks

Interop from ClojureScript doesn't seem to work since v0.53 #4050

trueneu opened this issue Nov 11, 2024 · 5 comments
Assignees

Comments

@trueneu
Copy link

trueneu commented Nov 11, 2024

Brief summary

Starting from k6 v0.53, it is not possible to call any http methods from ClojureScript for no obvious reason. It seems that imports stopped working correctly.

k6 version

v0.53, v0.54

OS

Ubuntu 22.04

Docker version and image (if applicable)

No response

Steps to reproduce the problem

I am using shadow-cljs to compile ClojureScript with the following relevant configuration:

            :target           :esm
            :js-options       {:keep-as-import #{"k6" "k6/http" "k6/crypto" "k6/encoding"}}
            :modules          {:main {:exports {default k6-test.core/default
                                                options k6-test.core/options
                                                setup   k6-test.core/setup}}}
            :compiler-options {:optimizations      :advanced
                               :output-feature-set :es5}}

Then, I import k6/http (the results are the same):

(:require ["k6/http" :as http])
_or_
(:require ["k6/http$default" :as http])

k6 v0.52 will make an http call if I do

(http/get url)

However, starting from v0.53, it complains there's no such method.

If I do (js/Object.keys http), with v0.52 everything's fine:

["TLS_1_0","TLS_1_1","TLS_1_2","TLS_1_3","OCSP_STATUS_GOOD","OCSP_STATUS_REVOKED","OCSP_STATUS_SERVER_FAILED","OCSP_STATUS_UNKNOWN","OCSP_REASON_UNSPECIFIED","OCSP_REASON_KEY_COMPROMISE","OCSP_REASON_CA_COMPROMISE","OCSP_REASON_AFFILIATION_CHANGED","OCSP_REASON_SUPERSEDED","OCSP_REASON_CESSATION_OF_OPERATION","OCSP_REASON_CERTIFICATE_HOLD","OCSP_REASON_REMOVE_FROM_CRL","OCSP_REASON_PRIVILEGE_WITHDRAWN","OCSP_REASON_AA_COMPROMISE","url","CookieJar","cookieJar","file","get","head","post","put","patch","del","options","request","asyncRequest","batch","setResponseCallback","expectedStatuses","default"]

With v0.53 onwards, it's either an empty array (regular require), or this ($default require):

TypeError: Cannot convert undefined or null to object
        at keys (native)

If I perform the same from TypeScript code, everything's fine with the new version.

Basically, imports from ClojureScript don't work anymore. All things given, I assume this is a regression from v0.52 behaviour.

Could something change in the runtime ESM support that breaks this between the v0.52 and v0.53? I see CJS/ESM related breaking changes listed for v0.53, but I don't quite understand from the description how they are related.

Thomas Heller, the author of shadow-cljs, was kind to provide his expertise and has debugged it with me, but he also has no idea why this doesn't work as the code emitted by shadow-cljs should work if ESM is implemented correctly by the runtime.

Expected behaviour

k6/http is imported correctly and all the methods are callable.

Actual behaviour

TypeError: Object has no member 'get'

Tasks

@ankur22
Copy link
Contributor

ankur22 commented Nov 11, 2024

Hi @trueneu,

Thanks for opening an issue. To help us replicate the issue, could you provide us with a working script that works in v0.52 and doesn't work in v0.53 of k6?

@trueneu
Copy link
Author

trueneu commented Nov 11, 2024

@ankur22 Sure thing, I'll have to spend some time to put together a minimal example with an instruction. If I upload it to a separate GitHub repo would that work for you?

Or do you want a compiled JS without the source?

@trueneu
Copy link
Author

trueneu commented Nov 11, 2024

@ankur22 , anyways, here's a repo with an example and a README to reproduce: https://github.com/trueneu/k6-bug

@trueneu
Copy link
Author

trueneu commented Nov 16, 2024

@ankur22 FWIW, I tried running against k6 built from your branch and it works, thank you very much! :)

We can close this now and reopen if it resurfaces for any reason, or close it after a new k6 version is released, whatever works.

@ankur22
Copy link
Contributor

ankur22 commented Nov 18, 2024

Great news, @trueneu! Thanks for being proactive and checking against your own scripts 😄 🎉 The fix will make it into the next release, so you should be able to work with that instead of a custom build once that has been released.

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

2 participants