Badgerati / Pode

Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
https://badgerati.github.io/Pode
MIT License
832 stars 92 forks source link

408 RequestTimeout not rendering any error page #1396

Open beesanne opened 2 days ago

beesanne commented 2 days ago

Not sure if I'm just missing something here but I am trying to set a custom error page for when it times out but right now its just returning a blank page with or without the custom page set up.

I am on Pode version - 2.10.1

I have a 408.json file inside of /errors: {"Response": "Operation took too long"}

server.psd1 has: Web = @{ ErrorPages = @{ ShowExceptions = $true Default = "application/json" StrictContentTyping = $true } }

when i force a timeout by setting the request to 5 second timeout i would expect it to return a 408 error (which it does) and then render the error page (which it does not). I have tried this with a 404 error by typing in a route that does not exist and it does automatically return the custom 404 error. Do 408 errors not work this same way or am i just doing something wrong?

Badgerati commented 12 hours ago

For 408 this is expected, the handling of the timeout is done further up the stack within the .NET code, rather than within the PowerShell code so it's difficult to handle and send back the customised response. When the timeout occurs, it's handled by a separate process which terminates the current thread, and forces a 408 response back to the client.

There are a couple other HTTP status codes which are the same, typically 5XX ones. They're handled further up the stack and it's difficult to customise the response.

I'll have a think, in case there's anything I can do with 408s.