Skip to content

Issues with interrupting Plutip tests with Ctrl+C #1580

@mikekeke

Description

@mikekeke

I'm experiencing the following issue (at least up to the v6.0.0 release) when interrupting Plutip tests: after pressing Ctrl+C I see this error in the terminal

node:internal/fs/utils:350
    throw err;
    ^

Error: ENOENT: no such file or directory, lstat '/tmp/nix-shell.Od5tH5/kupo-db'
    at Object.lstatSync (node:fs:1668:3)
    at __node_internal_ (node:internal/fs/utils:825:8)
    at Object.rmSync (node:fs:1275:13)
    at /home/mike/dev/mlabs/clarity-project/my-ctl-fork/output/Ctl.Internal.Plutip.Spawn/foreign.js:9:39
    at ChildProcess.<anonymous> (/home/mike/dev/mlabs/clarity-project/my-ctl-fork/output/Node.ChildProcess/foreign.js:88:40)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12) {
  errno: -2,
  syscall: 'lstat',
  code: 'ENOENT',
  path: '/tmp/nix-shell.XXX/kupo-db'
}

It seems like this is caused by Kupo having two handlers that attempt to delete test directory: one on SIGINT and one on exit. In the case of pressing Ctrl+C, kupo-db is deleted by the on-SIGINT handler, and then the onexit handler fails to delete the nonexistent directory.

Some other consequences I've noticed besides error in the terminal: sometimes I see that directory of test cluster was not deleted from temp directory.

Although, after fixing this issue in some simplest way (e.g. adding try to directory deletion in onexit handler) I'm facing another issue: after pressing Ctrl+C process detaches instead of exiting and test suite runs till completion. I was testing with suite like this

suite :: TestPlanM (Aff Unit) Unit
suite = do
  test
    "interruption test-1" $ do
    withPlutipContractEnv ctcPlutipConfig testDistribution
      \env wallet -> do
        do
          runContractInEnv env $ withKeyWallet wallet do
            logInfo' "starting delay 10s - press CTRL + C"
            liftAff $ delay (Milliseconds (10000.0 :: Number))
            logInfo' "delay end"
            logInfo' "test end"
  test
    "interruption test -2" $ do
    withPlutipContractEnv ctcPlutipConfig testDistribution
      \env wallet -> do
        do
          runContractInEnv env $ withKeyWallet wallet do
            logInfo' "second test"

and if I press Ctrl+C after "starting delay 10s - press CTRL + C" log message, when delay is over I still see
"delay end" and "test end" messages, as well as execution of "interruption test -2"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions