Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

When Reedline may encounter "The cursor position could not be read within a normal duration"? #870

Open
tisonkun opened this issue Jan 3, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@tisonkun
Copy link
Contributor

tisonkun commented Jan 3, 2025

I wonder when Reedline may encounter the internal error "The cursor position could not be read within a normal duration".

I can't stably reproduce it but here is the structure of my code:

    let mut state = Reedline::create()
        .with_validator(Box::new(ScopeQLValidator))
        .with_highlighter(Box::new(ScopeQLHighlighter));

    loop {
        let input = state
            .read_line(&prompt)
            .change_context_lazy(|| Error::Other("failed to read next line".to_string()))?;
        let input = match input {
            Signal::CtrlC | Signal::CtrlD => {
                println!("exit");
                break;
            }
            Signal::Success(input) => input,
        };
        let input = input.trim();

        // other biz code

        state.run_edit_commands(&[EditCommand::InsertString(
            outstanding.trim_start().to_string(),
        )]);
    }

And today in Ubuntu Terminal I encounter:

thread 'main' panicked at cmd/scopeql/src/main.rs:50:78:
called `Result::unwrap()` on an `Err` value: failed to read next line
|- at cmd/scopeql/src/repl/entrypoint.rs:42:14
|
| -> The cursor position could not be read within a normal duration
    | - at cmd/scopeql/src/repl/entrypoint.rs:42:14

I have no idea when this error may occur and find no way to investigate deeper.

@tisonkun tisonkun added the bug Something isn't working label Jan 3, 2025
@fdncred
Copy link
Collaborator

fdncred commented Jan 3, 2025

@tisonkun
Copy link
Contributor Author

tisonkun commented Jan 3, 2025

@fdncred Yeah.

Do you have some information here to investigate more? Anyway, it's hidden behind reedline's API. I don't know how the error variant can be hit here.

@fdncred
Copy link
Collaborator

fdncred commented Jan 3, 2025

Not really. It looks to me like crossterm is asking the terminal for the cursor position, waits 2 seconds without a response and then times out with that error.

@tisonkun
Copy link
Contributor Author

tisonkun commented Jan 3, 2025

Well. I have no background how "asking for cursor position" can hang or fail :P

@fdncred
Copy link
Collaborator

fdncred commented Jan 3, 2025

Me either. It may be worth asking on the crossterm repo. I just looks like if crossterm fails to get a lock for the event reader it would fail. I'm not sure what would cause that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants