Skip to content

RunWithContext takes a long time to run after context is cancelled #292

@TarakanoLov

Description

@TarakanoLov

Hello, I expected that when calling RunWithContext the execution time would be limited to five seconds, but in fact the code runs for more than two minutes.
Is this expected behavior? Is there anything I can do to accurately limit the execution time?

Version: github.com/itchyny/gojq v0.12.19
Code:

package main

import (
    "github.com/itchyny/gojq"
    "context"
    "time"
)

func main() {
    parsed, err := gojq.Parse("capture(\"^\"*78888880)")
    if err != nil {
        panic(err)
    }

    code, err := gojq.Compile(parsed)
    if err != nil {
        panic(err)
    }

    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
    defer cancel()

    iter := code.RunWithContext(ctx, "hello")
    _, _ = iter.Next()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions