Skip to content

Don't loop forever if the template fails to render #1427

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

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Jun 21, 2021

Instead, panic, which only fails one request instead of sending the
server into an infinite loop.

This shouldn't ever happen in practice since error pages are tested in
CI, but it's nice just in case.

The panic looks like this:

2021/06/21 00:05:07 [ERROR] docs_rs::web::page::web_page: called ctry!() on an `Err` value: Error { kind: Msg("Failed to render 'error.html'"), source: Some(Error { kind: Msg("Variable `oops` not found in context while rendering 'error.html'"), source: None }) }
note: while attempting to fetch the route Url { generic_url: "http://localhost:3000/not_here" }
   4: docs_rs::web::page::web_page::WebPage::into_response<docs_rs::web::ErrorPage>
             at src\web\page\web_page.rs:74
   5: docs_rs::web::error::{{impl}}::handle
             at src\web\error.rs:78
   6: iron::middleware::{{impl}}::handle
             at C:\Users\Joshua Nelson\.cargo\registry\src\github.com-1ecc6299db9ec823\iron-0.6.1\src\middleware\mod.rs:395
  10: docs_rs::web::{{impl}}::handle::{{closure}}
             at src\web\mod.rs:241
  11: enum$<core::result::Result<iron::response::Response, iron::error::IronError>>::or_else<iron::response::Response,iron::error::IronError,iron::error::IronError,closure-2>
             at /rustc/cc77ba46fcb2d288aa01554b48cd586c5827c3dd\library\core\src\result.rs:770
  12: docs_rs::web::{{impl}}::handle
             at src\web\mod.rs:183
  13: iron::iron::{{impl}}::handle<docs_rs::web::MainHandler>
             at C:\Users\Joshua Nelson\.cargo\registry\src\github.com-1ecc6299db9ec823\iron-0.6.1\src\iron.rs:176

thread '<unnamed>' panicked at 'error while serving error page: Error { kind: Msg("Failed to render 'error.html'"), source: Some(Error { kind: Msg("Variable `oops` not found in context while rendering 'error.html'"), source: None }) }', src\web\page\web_page.rs:72:20

Fixes #1087.

r? @Nemo157

@jyn514 jyn514 added A-backend Area: Webserver backend S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Jun 21, 2021
Instead, panic, which only fails one request instead of sending the
server into an infinite loop.

This shouldn't ever happen in practice since error pages are tested in
CI, but it's nice just in case.

The panic looks like this:

```
2021/06/21 00:05:07 [ERROR] docs_rs::web::page::web_page: called ctry!() on an `Err` value: Error { kind: Msg("Failed to render 'error.html'"), source: Some(Error { kind: Msg("Variable `oops` not found in context while rendering 'error.html'"), source: None }) }
note: while attempting to fetch the route Url { generic_url: "http://localhost:3000/not_here" }
   4: docs_rs::web::page::web_page::WebPage::into_response<docs_rs::web::ErrorPage>
             at src\web\page\web_page.rs:74
   5: docs_rs::web::error::{{impl}}::handle
             at src\web\error.rs:78
   6: iron::middleware::{{impl}}::handle
             at C:\Users\Joshua Nelson\.cargo\registry\src\github.com-1ecc6299db9ec823\iron-0.6.1\src\middleware\mod.rs:395
  10: docs_rs::web::{{impl}}::handle::{{closure}}
             at src\web\mod.rs:241
  11: enum$<core::result::Result<iron::response::Response, iron::error::IronError>>::or_else<iron::response::Response,iron::error::IronError,iron::error::IronError,closure-2>
             at /rustc/cc77ba46fcb2d288aa01554b48cd586c5827c3dd\library\core\src\result.rs:770
  12: docs_rs::web::{{impl}}::handle
             at src\web\mod.rs:183
  13: iron::iron::{{impl}}::handle<docs_rs::web::MainHandler>
             at C:\Users\Joshua Nelson\.cargo\registry\src\github.com-1ecc6299db9ec823\iron-0.6.1\src\iron.rs:176

thread '<unnamed>' panicked at 'error while serving error page: Error { kind: Msg("Failed to render 'error.html'"), source: Some(Error { kind: Msg("Variable `oops` not found in context while rendering 'error.html'"), source: None }) }', src\web\page\web_page.rs:72:20
```
@jyn514 jyn514 merged commit dfe6093 into rust-lang:master Jun 21, 2021
@jyn514 jyn514 deleted the infinite-error branch June 21, 2021 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend Area: Webserver backend S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An error during template rendering could throw the server into an infinite loop
2 participants