slimtoolkit/slim · error
waiting for %v event: %w
Error message
waiting for %v event: %w
What it means
ExecuteWaitEvenCommand wraps any failure from waitForEvent (which polls an events file for a target event.Type) with the message "waiting for %v event: %w". The library throws it when the wait cannot complete: the events file never contains the expected event, the context is cancelled/deadline exceeded, or the events file cannot be read/parsed. It is a wrapper, so the root cause is always in the wrapped error (%w).
Source
Thrown at pkg/app/sensor/standalone/control/wait.go:20
import (
"bufio"
"context"
"fmt"
"os"
"strings"
"time"
"github.com/slimtoolkit/slim/pkg/ipc/event"
)
func ExecuteWaitEvenCommand(
ctx context.Context,
eventsFile string,
evt event.Type,
) error {
if err := waitForEvent(ctx, eventsFile, evt); err != nil {
return fmt.Errorf("waiting for %v event: %w", evt, err)
}
return nil
}
func waitForEvent(ctx context.Context, eventsFile string, target event.Type) error {
for ctx.Err() == nil {
found, err := findEvent(eventsFile, target)
if err != nil {
return err
}
if found {
return nil
}
time.Sleep(1 * time.Second)
}View on GitHub (pinned to 81940d17fa)
Solutions
- Inspect the wrapped error: if it is context.DeadlineExceeded, increase the context timeout or fix why the event never appears.
- Verify the eventsFile path is correct and the producing component is actually running and writing to it (ls/tail the file while waiting).
- Confirm the event.Type passed matches what the sensor actually publishes (check event definitions).
- Ensure the sensor under test started successfully before waiting; check its logs for startup failures.
Example fix
// before
ctx := context.Background()
err := ExecuteWaitEvenCommand(ctx, eventsFile, event.StartMonitor)
// after
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
if _, statErr := os.Stat(eventsFile); statErr != nil {
log.Fatalf("events file missing: %v", statErr)
}
err := ExecuteWaitEvenCommand(ctx, eventsFile, event.StartMonitor) Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat(eventsFile); err != nil {
return fmt.Errorf("events file not available: %w", err)
}
if ctx.Err() != nil {
return fmt.Errorf("context already done: %w", ctx.Err())
} Try / catch
err := ExecuteWaitEvenCommand(ctx, eventsFile, event.StartMonitor)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
log.Printf("event never arrived within deadline; check sensor health")
}
return fmt.Errorf("wait for event aborted: %w", err)
} Prevention
- Always pass a context with an explicit timeout and handle DeadlineExceeded distinctly.
- Confirm the sensor writes to eventsFile before waiting (stat/tail the file).
- Use the exact event.Type constants from the event package, not ad-hoc strings.
- Check sensor startup logs before polling so you fail fast on a dead sensor.
When it happens
Trigger: Calling ExecuteWaitEvenCommand(ctx, eventsFile, evt) when the context is cancelled before the event appears, the eventsFile does not exist or is not being written to, or waitForEvent's polling loop hits its internal timeout/error while scanning for evt.
Common situations: Integration tests waiting for a sensor event that never fires because the sensor crashed or never started; CI jobs with too-short context deadlines; wrong path passed for eventsFile so the poller reads a stale or missing file; expecting an event type the component never emits (e.g. typo'd event.Type).
Related errors
- start monitor timeout
- start monitor timeout
- sensor shutdown before monitor stop
- ambiguous start command: cannot use [app_name,app_args] and
- file path is not absolute
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/3f8eca3b3e0f80c9.
Report an issue: GitHub.