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

select in JS hangs #609

Closed
fvasco opened this issue Sep 24, 2018 · 6 comments
Closed

select in JS hangs #609

fvasco opened this issue Sep 24, 2018 · 6 comments
Assignees
Labels

Comments

@fvasco
Copy link
Contributor

fvasco commented Sep 24, 2018

This test does not complete in Node.js 8.10.0:

import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.selects.select
import kotlin.test.Test

class Test {
    @Test
    fun test() = GlobalScope.promise {
        fun asyncDelay(millis: Long) = async {
            println("Delay $millis")
            delay(millis)
            millis
        }

        val list: List<Deferred<Long>> = (0L..5L).map { asyncDelay(it) }

        val res: Long = select {
            for (item in list) {
                item.onAwait { it }
            }
        }
        println("Done $res")
    }
}

Output

    Test
Delay 0

Similar hang for 1L..5L range

package.json

{
  "name": "testjs",
  "version": "1.0.0",
  "description": "",
  "author": "",
  "license": "",
  "dependencies": {
    "kotlin": "^1.2.70",
    "kotlinx-coroutines-core": "^0.26.1",
    "source-map-support": "^0.5.6"
  },
  "devDependencies": {
    "kotlin-test": "^1.2.70",
    "mocha": "^5.2.0"
  }
}
@qwwdfsad
Copy link
Member

qwwdfsad commented Sep 24, 2018

I've updated (locally) kx.c node and mocha versions to 0.8.10 and 5.2.0 and copied your test, it passes successfully:

    PromiseTest
Delay 0
Delay 1
Delay 2
Delay 3
Delay 4
Delay 5
Done 0
      ✓ test

Could you please provide self-contained reproducer? Maybe you have compiler or library versions clash?

@fvasco
Copy link
Contributor Author

fvasco commented Sep 25, 2018

Code in https://github.com/fvasco/testjs-job-hang

run

docker build -t test  .
docker run test

Some info:

$ uname -a
Linux HPeliteBook755 4.4.0-135-generic #161-Ubuntu SMP Mon Aug 27 10:45:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ cat /proc/cpuinfo |grep name
model name      : AMD PRO A12-8800B R7, 12 Compute Cores 4C+8G
model name      : AMD PRO A12-8800B R7, 12 Compute Cores 4C+8G
model name      : AMD PRO A12-8800B R7, 12 Compute Cores 4C+8G
model name      : AMD PRO A12-8800B R7, 12 Compute Cores 4C+8G

@fvasco
Copy link
Contributor Author

fvasco commented Sep 27, 2018

Hi @qwwdfsad
I have updated the test case to 0.27.0 version, the bug is still present.

@SUPERCILEX
Copy link
Contributor

I'm seeing this too

@elizarov
Copy link
Contributor

elizarov commented Oct 1, 2018

It seems to be related to this bug: Kotlin/kotlinx-atomicfu#32

@fvasco
Copy link
Contributor Author

fvasco commented Oct 2, 2018

Thank you for fix.

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

4 participants