Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that we have a correct stack trace during async rendering in dev #1453

Merged
merged 1 commit into from Nov 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/core-tags/core/await/renderer.js
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