Skip to content

Commit

Permalink
Make sure that we have a correct stack trace during async rendering i…
Browse files Browse the repository at this point in the history
…n dev
  • Loading branch information
cc-ebay committed Nov 15, 2019
1 parent 0414fe8 commit 7fa1282
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core-tags/core/await/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,19 @@ function requestData(provider, timeout) {
timeout = 10000;
}

var error;
var errorMsg = "Timed out after " + timeout + "ms";
// eslint-disable-next-line no-constant-condition
if ("MARKO_DEBUG") {
// Make sure we have a meaningful stack trace in development preparing the stacktrace upfront.
// If we create it inside the setTimeout, we will end up with a short, not meaningful, stack trace
// We only do it in development to avoid overhead in production
error = new Error(errorMsg);
}
if (timeout > 0) {
let timeoutId = setTimeout(function() {
timeoutId = null;
var error = new Error("Timed out after " + timeout + "ms");
if (!error) error = new Error(errorMsg);
error.code = "ERR_AWAIT_TIMEDOUT";
error.name = "TimeoutError";
asyncValue.___reject(error);
Expand Down

0 comments on commit 7fa1282

Please sign in to comment.