# Logs truncated every failed build

**URL:** <https://travis-ci.community/t/logs-truncated-every-failed-build/7159>\
**Category:** Travis CI Discussions & Feedback\
**Created:** [February 9, 2020, 12:13pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159 "2020-02-09T12:13:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bilge](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bilge/32/3791_2.png) [@Bilge](https://travis-ci.community/u/Bilge)\
**Post date:** [February 9, 2020, 12:13pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/1 "2020-02-09T12:13:52Z")

</div>

Every time a build fails, Travis fails to capture the tail end of the output. It typically chops off a dozen or so lines, often making it difficult or impossible to determine the reason for failure. This has been going on for years, although if we go back far enough, it never used to be a problem. Infrastructure changes a long time ago introduced this bug but I never reported it because I assumed something so critical would be fixed in short order. Clearly I was wrong.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 9, 2020, 2:46pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/2 "2020-02-09T14:46:58Z")

</div>

When reporting problems, please include relevant build URLs. Thanks.

---

<div class="post-metadata">

**Author:** ![Bilge](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bilge/32/3791_2.png) [@Bilge](https://travis-ci.community/u/Bilge)\
**Post date:** [February 9, 2020, 2:59pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/3 "2020-02-09T14:59:14Z")

</div>

OK, [here’s a failed build](https://travis-ci.org/250/Steam-250/builds/647975717).

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 10, 2020, 2:00am UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/4 "2020-02-10T02:00:28Z")

</div>

You are telling the build to `exit` when the command fails.

[https://travis-ci.org/250/Steam-250/builds/637200962#L503](https://travis-ci.org/250/Steam-250/builds/637200962#L503)

> <https://github.com/250/Steam-250/blob/712c19b22d8c3ddb1d6e19576cfcd17b441ef8e0/.travis.yml#L45>

Don’t do that.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 10, 2020, 2:01am UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/5 "2020-02-10T02:01:55Z")

</div>

If you don’t want the next command upon failure, you can put that command in `after_success` instead.

---

<div class="post-metadata">

**Author:** ![Bilge](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bilge/32/3791_2.png) [@Bilge](https://travis-ci.community/u/Bilge)\
**Post date:** [February 10, 2020, 5:26pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/6 "2020-02-10T17:26:58Z")

</div>

That solution doesn’t make sense, because the output is complete _before_ `exit` is invoked. To be clear, it should not be possible for any script to truncate output that has already been emitted. Whatever is output should be captured by the job exactly as it appeared. Instead, the compete error message is emitted but Travis fails to capture it, whether or not because `exit` was called _after_ the failure. To put it another way: it is not at all intuitive that `exit` would _delete_ output already emitted, which is what is happening here.

---

<div class="post-metadata">

**Author:** ![Bilge](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bilge/32/3791_2.png) [@Bilge](https://travis-ci.community/u/Bilge)\
**Post date:** [February 10, 2020, 5:47pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/7 "2020-02-10T17:47:36Z")

</div>

That’s not an equivalent solution, because any step in `after_success` cannot fail the build. I want both commands in `script` to be able to fail the build independently.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 10, 2020, 6:16pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/8 "2020-02-10T18:16:48Z")

</div>

Your job is finishing before the buffer is flushed and sent over the ssh connection to the logs.

You’re right about `after_success`, but ultimately you will need to remove the `exit` command in order to get what you want.

---

<div class="post-metadata">

**Author:** ![Bilge](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bilge/32/3791_2.png) [@Bilge](https://travis-ci.community/u/Bilge)\
**Post date:** [February 10, 2020, 9:34pm UTC](https://travis-ci.community/t/logs-truncated-every-failed-build/7159/9 "2020-02-10T21:34:19Z")

</div>

Sure, that may be what’s happening behind the scenes, but don’t you think that’s a technical issue with your implementation? It simply shouldn’t be possible to lose part of the logs due to user scripting. It shouldn’t be possible for me to prematurely terminate the SSH connection. There should be a wrapper that ensures everything is flushed when the job ends so this problem cannot occur.
