You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ktor Version and Engine Used (client or server and name)
ktor 1.3.0
Describe the bug
When performing a simple get request via the compiled JS code in a Kotlin multiplatform project using ktor, the following error is thrown:
(node:46932) UnhandledPromiseRejectionWarning: Error: Cannot find module 'abort-controller'
Require stack:
- /example-js/node_modules/ktor-ktor-client-core.js
- /example-js/node_modules/ktor-ktor-client-auth.js
- /example-js/node_modules/common.js
- /testRest.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at AbortController_0 (/example-js/node_modules/ktor-ktor-client-core.js:15169:24)
at /example-js/node_modules/ktor-ktor-client-core.js:15106:20
at /example-js/node_modules/ktor-ktor-client-core.js:15081:3
at Coroutine$commonFetch.doResume (/example-js/node_modules/ktor-ktor-client-core.js:15136:116)
at commonFetch (/example-js/node_modules/ktor-ktor-client-core.js:15164:23)
at Coroutine$execute_dkgphz$.doResume (/example-js/node_modules/ktor-ktor-client-core.js:14513:25)
To Reproduce
Setup a Kotlin multiplatform project so that when you build via gradle, Kotlin generates the node_modules folder with your JS code including kotlin.js and common.js via the assembleJs gradle task. Then try to perform a simple get request using the ktor client like so:
test.kt in common/src/jsMain/kotlin/com.myApp/test.kt:
suspend fun getGoogle(): String {
val client = HttpClient()
return client.get<String>("https://www.google.de")
}
fun returnPromise(): Promise<String> = //or Promise<Unit> for voids
GlobalScope.promise {
getGoogle() // return a String
}
testRest.js in example-js/:
const common = require("./node_modules/common")
console.log(common.returnPromise())
Also, when I add the actual abort-controller manually via npm, I just get another error about it missing another module, so I gave up at that point.
Expected behavior
Perform the get request and return the content of the requested web page.
The text was updated successfully, but these errors were encountered:
Ktor Version and Engine Used (client or server and name)
ktor 1.3.0
Describe the bug
When performing a simple get request via the compiled JS code in a Kotlin multiplatform project using ktor, the following error is thrown:
To Reproduce
Setup a Kotlin multiplatform project so that when you build via gradle, Kotlin generates the
node_modules
folder with your JS code includingkotlin.js
andcommon.js
via theassembleJs
gradle task. Then try to perform a simple get request using the ktor client like so:test.kt
incommon/src/jsMain/kotlin/com.myApp/test.kt
:testRest.js
inexample-js/
:Also, when I add the actual abort-controller manually via npm, I just get another error about it missing another module, so I gave up at that point.
Expected behavior
Perform the get request and return the content of the requested web page.
The text was updated successfully, but these errors were encountered: