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

Add error metadata to index.html to forward backend errors #1907

Closed
kylecarbs opened this issue May 30, 2022 · 0 comments · Fixed by #2067
Closed

Add error metadata to index.html to forward backend errors #1907

kylecarbs opened this issue May 30, 2022 · 0 comments · Fixed by #2067
Assignees
Labels
api Area: HTTP API
Milestone

Comments

@kylecarbs
Copy link
Member

When the browser accesses the API for authentication redirection or accessing apps, displaying a JSON error isn't useful! In these circumstances, we should serve index.html with an injected error and status code to display.

VS Code does this in meta tags with {{WORKBENCH_WEB_CONFIGURATION}}:
https://github.com/microsoft/vscode/blob/8a8c175605bb3503dc4515700dfd8dcf68dac98b/src/vs/code/browser/workbench/workbench.html#L19-L20

To display a helpful error in the frontend, we should get the status code and response text:

<meta id="api-response" data-statuscode="{{API_STATUS_CODE}}" data-message="{{API_MESSAGE}}" />

An example of this is accessing a web app, where it may be offline. This results in a 502 error right now, which isn't helpful to the user. We could send the following to the frontend instead:

<meta id="api-response" data-statuscode="404" data-message="code-server isn't running! Make sure it's active on 'localhost:3000'." />

This is injected dynamically using a string replace by our static server in Go. The frontend could register on a per-path basis to display really friendly errors, but for now we could do a catch-all by making our 404 page check if data-statuscode is set. If so, we'll display the error!

@misskniss misskniss added the api Area: HTTP API label Jun 1, 2022
@kylecarbs kylecarbs self-assigned this Jun 6, 2022
kylecarbs added a commit that referenced this issue Jun 6, 2022
Fixes #1907 and #805.

I'll make this pretty in another PR!
kylecarbs added a commit that referenced this issue Jun 6, 2022
* fix: Use proper webpack config for dev mode

This was broken when improving the build times. The typechecker
unfortunately missed it!

* feat: Add links to the resource card for workspace applications

Fixes #1907 and #805.

I'll make this pretty in another PR!

* Improve style
kylecarbs added a commit that referenced this issue Jun 10, 2022
* fix: Use proper webpack config for dev mode

This was broken when improving the build times. The typechecker
unfortunately missed it!

* feat: Add links to the resource card for workspace applications

Fixes #1907 and #805.

I'll make this pretty in another PR!

* Improve style
@misskniss misskniss added this to the Community MVP milestone Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants