slimtoolkit/slim · error
error waiting for sensor event: %w
Error message
error waiting for sensor event: %w
What it means
In runControlCommand, the 'wait-for-event' control command calls control.ExecuteWaitEvenCommand to block until the named event is received through the events file. If that wait fails (file I/O error, timeout, malformed event stream), the error is wrapped as 'error waiting for sensor event' and returned from Run.
Source
Thrown at pkg/app/sensor/app.go:321
func runControlCommand(ctx context.Context) error {
if len(os.Args) < 3 {
return errors.New("missing command")
}
cmd := control.Command(os.Args[2])
switch cmd {
case control.StopTargetAppCommand:
if err := control.ExecuteStopTargetAppCommand(ctx, *commandsFile); err != nil {
return fmt.Errorf("error stopping target app: %w", err)
}
case control.WaitForEventCommand:
if len(os.Args) < 4 {
return errors.New("missing event name")
}
if err := control.ExecuteWaitEvenCommand(ctx, eventsFilePath(), event.Type(os.Args[3])); err != nil {
return fmt.Errorf("error waiting for sensor event: %w", err)
}
default:
return fmt.Errorf("unknown command: %s", cmd)
}
return nil
}
View on GitHub (pinned to 81940d17fa)
Solutions
- Check the wrapped inner error to distinguish file errors from timeouts.
- Confirm the events file path (eventsFilePath()) points to a writable, existing directory.
- Verify the event name (os.Args[3]) exactly matches an event the target app emits.
- Increase the context timeout if the event legitimately takes long to fire.
Defensive patterns
Strategy: try-catch
Validate before calling
if len(os.Args) < 4 {
return errors.New("missing event name")
}
if _, err := os.Stat(filepath.Dir(eventsFilePath())); err != nil {
return fmt.Errorf("events dir missing: %w", err)
} Type guard
func isValidEventType(name string) bool {
_, ok := event.TypeFromString(name) // or membership check in known events
return ok
} Try / catch
err := app.Run(ctx)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) && strings.Contains(err.Error(), "waiting for sensor event") {
return fmt.Errorf("event %q never arrived within deadline; check event name and emitter", os.Args[3])
}
return err
} Prevention
- Match event names exactly against the event.Type constants the target emits
- Pre-create the events directory with correct permissions
- Set a generous but bounded context deadline for the wait
When it happens
Trigger: Running the sensor with the WaitForEventCommand and an event name from os.Args[3] while ExecuteWaitEvenCommand fails — events file cannot be created/read, the expected event never arrives before the context is cancelled, or the event type is invalid.
Common situations: Context deadline exceeded because the target app never emitted the event; events file directory deleted or read-only; typo in the event name so the sensor waits forever then times out.
Related errors
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/169b18f8661245a1.
Report an issue: GitHub.