question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Skipping a Task with an active prompt

See original GitHub issue

In one of my use cases, I would like the user to press a key if they want to interrupt the current task, otherwise continue on.

For example, I have an enquirer prompt that is something like the following Press any key to abort, otherwise continuing in 10 seconds...

However, when I skip the task while the prompt is active, the task get skipped but the prompt is still active in the background.

If I try to cancel the prompt, I always get hit with an error so that too exits the pipeline


    enquirer.on("prompt", async prompt => {
      await delay(10000);
      prompt.cancel();
    });

Lastly, if I try to skip the prompt with the built in skip function (which accepts a Promise<boolean> type), the prompt disappears into the background but is still active until it gets skipped

const status = await task.prompt({
    name: "continue",
    type: "input",
    message: `Press any key to abort, continuing in 10 seconds otherwise`,
    skip: async () => {
        await delay(10000);
        return true;
    }
});

What would be the appropriate approach for this pattern? I can make a contribution for it as well

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
cenk1cenk2commented, Sep 19, 2020

This should work for examples, no need to build them if I get you correctly.

yarn example examples/get-user-input.example.ts

If you install all the dependencies as you did to build the project, I think linking should work but enquirer is not installed as production dependency. So I am not sure what went wrong.

The easier way of doing this is running the docker-compose stack and linking the package to your project via npm. Since it will recompile on changes.

1reaction
cenk1cenk2commented, Sep 19, 2020

Yeah I agree on that part as well.

If ctrl-c -> error via skip or cancelledprompt or such -> no error, just carry on

Read more comments on GitHub >

github_iconTop Results From Across the Web

Skip tasks [MA] depending on the value of user prompt
The way i do this is in an Orchestrator Runbook. Based on the value (which is mapped to an extended field) i then...
Read more >
How can I skip plays using user's prompts? - ansible
1 Answer 1 · I added your code to my playbook, but when running it, all tasks are skipped, even if I type...
Read more >
schtasks commands - Microsoft Learn
Schedules commands and programs to run periodically or at a specific time, adds and removes tasks from the schedule, starts and stops tasks...
Read more >
Skipping Scheduled Tasks While the Automation Engine Is Stopped
Automation Engine option as shown below. All tasks that would have been submitted to the Automation Engine will be skipped without being written...
Read more >
Tasks in Visual Studio Code
The TypeScript compiler tsc has built in support for this via the --watch command line option. To provide feedback that a background task...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found