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 8332729
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 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,18 @@ function requestData(provider, timeout) {
timeout = 10000;
}

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

0 comments on commit 8332729

Please sign in to comment.