# types.TmuxEventStream.find

- **Module:** types.TmuxEventStream
- **Package:** @libtmux/libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/2cb93308200da38a26b59876618116850f110607/packages/libtmux/src/types.ts#L839
- **Page:** https://libtmux.org/reference/ts/types-tmuxeventstream-find/

```
types.TmuxEventStream.find(matches: : (event: TmuxEvent) => event is Match, options: : { readonly timeoutMs?: number }) -> Promise<Match | undefined>
```

Resolve with the first event `matches` accepts, or undefined if the deadline passes or the stream is closed first.

This consumes the stream, which is what iterating it does anyway. It exists
because every caller otherwise writes the same loop, deadline, and cleanup,
and forgetting the deadline turns a missed event into a hang.

## Raises

- `LibTmuxException` — when the stream ends under the wait — the server went away, or the connection dropped. Closing it on purpose is not that: a caller cancelling, or a scope ending, answers undefined, because deciding to stop waiting is not a failure anyone should have to catch. Undefined therefore means the deadline passed or the wait was called off, and only the deadline says the workload really did not print what was waited for. `timeoutMs`, when set, must be a positive timer-safe integer.
