Tracing Runtime Errors to Source Files in Bundled Trading Scripts
Summary
This document explains a debugging technique for trading systems whose JavaScript files are combined into one hosted script. It records the bundled line offset corresponding to a known line in each original file, then uses error stack information to map a runtime failure back to the original file and line. Wrapping a strategy function in a try/catch helper allows the system to log that location when an exception occurs.
The example preserves execution timeout errors by rethrowing them and logs other exceptions before rethrowing them, so normal error handling is not silently suppressed. The document gives illustrative implementation steps and a small example, but no test results or evidence that the stack format is stable across runtimes. Its method depends on predictable stack traces and correct line markers that execute before the relevant error; changes to bundling or runtime behavior could make the mapping inaccurate.
Key ideas
- Bundling multiple JavaScript files into one script obscures the original source locations of runtime errors.
- A marker can record each source file's line offset within the combined script.
- Stack trace line numbers can be mapped back to a file and its local line number.
- Wrapped functions can log the mapped location and rethrow exceptions, while treating execution timeouts specially.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.