1

I have a Rust web on a remote server which I run as:

  RUST_BACKTRACE=1 nohup  /home/my_user/app123 &

When it goes down and I check nohup.log, I see only this:

04:52:22 [WARN] unexpected chunk when body cannot write
04:52:23 [WARN] unexpected chunk when body cannot write
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorImpl { code: EofWhileParsingValue, line: 1, column: 0 }', /checkout/src/libcore/result.rs:906:4
stack backtrace:
   0: <std::time::Instant as core::fmt::Debug>::fmt
   1: <std::time::Instant as core::fmt::Debug>::fmt
   2: <std::time::Instant as core::fmt::Debug>::fmt
   3: <std::time::Instant as core::fmt::Debug>::fmt
   4: <std::time::Instant as core::fmt::Debug>::fmt
   5: <std::time::Instant as core::fmt::Debug>::fmt
   6: <std::time::Instant as core::fmt::Debug>::fmt
   7: <std::time::Instant as core::fmt::Debug>::fmt
   8: <core::cell::BorrowMutError as core::fmt::Debug>::fmt
   9: 
  10: 
  11: 
  12: 
  13: <hyper::version::HttpVersion as core::fmt::Debug>::fmt
  14: 
  15: <std::time::duration::Duration as core::fmt::Debug>::fmt
  16: <std::time::Instant as core::fmt::Debug>::fmt
  17: 
  18: <unknown>

How can I trace the error? It's something related to Serde JSON, but what exactly? There are many places in my app where it could occur.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
jerry
  • 827
  • 2
  • 7
  • 10
  • Why are 9, 10, ... empty? Also without any code, we can't do anything. Can you provide a [mcve](https://stackoverflow.com/help/mcve)? – hellow Mar 02 '18 at 07:29

1 Answers1

4

There aren't any line numbers in your stack backtrace so the binary running on your server must have been built without debug symbols. As described in How to get a release build with debugging information when using cargo?, add the following section to Cargo.toml of your main binary:

[profile.release]
debug = true

This will include filename and line number information in the binary that can be printed when a panic occurs, making your stack backtraces more useful in the future.

ErrorImpl { code: EofWhileParsingValue, line: 1, column: 0 }

For now, the best we can tell without a backtrace is that you tried to parse an empty JSON string. For example the following triggers the same error.

extern crate serde_json;

fn main() {
    let _: u64 = serde_json::from_str("").unwrap();
}

As a reminder, Result::unwrap() is not an appropriate way to handle errors in a production application. ;-)

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
dtolnay
  • 9,621
  • 5
  • 41
  • 62