# Eunit timeout in receive results in wrong location in stack trace

**URL:** <https://erlangforums.com/t/eunit-timeout-in-receive-results-in-wrong-location-in-stack-trace/4017>\
**Category:** Questions / Help\
**Tags:** possible-bug, eunit\
**Created:** [September 22, 2024, 10:05am UTC](https://erlangforums.com/t/eunit-timeout-in-receive-results-in-wrong-location-in-stack-trace/4017 "2024-09-22T10:05:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlipscombe](https://erlangforums.com/user_avatar/erlangforums.com/rlipscombe/32/459_2.png) [@rlipscombe](https://erlangforums.com/u/rlipscombe)\
**Post date:** [September 22, 2024, 10:05am UTC](https://erlangforums.com/t/eunit-timeout-in-receive-results-in-wrong-location-in-stack-trace/4017/1 "2024-09-22T10:05:28Z")

</div>

I’ve got some eunit code that looks a bit like this:

```erlang
    % ...
    meck:wait(m, f, '_', 2000), % L1
    receive % L2
        message1 -> ok
    end,
    receive % L3
        message2 -> ok
    end
    % ...

```

`message2` is never sent, so the `receive` at `L3` never completes, so `eunit` kills my test with a timeout. This is expected.

But: the location reported is `L1`, rather than the expected `L3`. It looks like `receive` expressions don’t appear in stack traces.

It’s probably not relevant that I’m using `meck` – if I add some code in between the two `receive` expressions, the reported location is that of the added code.

This is with Erlang/OTP 26.2.5.3.

---

<div class="post-metadata">

**Author:** ![rlipscombe](https://erlangforums.com/user_avatar/erlangforums.com/rlipscombe/32/459_2.png) [@rlipscombe](https://erlangforums.com/u/rlipscombe)\
**Post date:** [September 22, 2024, 10:14am UTC](https://erlangforums.com/t/eunit-timeout-in-receive-results-in-wrong-location-in-stack-trace/4017/2 "2024-09-22T10:14:58Z")

</div>

> [@rlipscombe](#):
>
> if I add some code

It appears the the added code needs to make a proper function call. If I use a throwaway atom or an inline anonymous function – `((fun() -> ok end)())` – then it still reports the wrong location. If I call, say `mark()`, where `mark() -> ignore.`, then the location is more correct (but still not that of the `receive`).
