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 pretty-error page infrastructure #436

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 136 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/tre/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ parameter in module format Workers.
must also be defined. Note the first module must be the entrypoint and have
type `"ESModule"`.

- `modulesRoot?: string`

If `modules` is set to an array, modules' "name"s will be their `path`s
relative to this value. This ensures file paths in stack traces are correct.

<!-- prettier-ignore-start -->
<!-- (for disabling `;` insertion in `js` code block) -->

Expand Down
2 changes: 2 additions & 0 deletions packages/tre/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
"glob-to-regexp": "^0.4.1",
"http-cache-semantics": "^4.1.0",
"kleur": "^4.1.5",
"source-map": "^0.7.4",
"stoppable": "^1.1.0",
"undici": "^5.12.0",
"workerd": "^1.20221111.5",
"ws": "^8.11.0",
"youch": "^3.2.2",
"zod": "^3.18.0"
},
"devDependencies": {
Expand Down
12 changes: 11 additions & 1 deletion packages/tre/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ import {
maybeGetSitesManifestModule,
normaliseDurableObject,
} from "./plugins";
import { HEADER_CUSTOM_SERVICE, getUserServiceName } from "./plugins/core";
import {
HEADER_CUSTOM_SERVICE,
SourceOptions,
getUserServiceName,
handlePrettyErrorRequest,
} from "./plugins/core";
import {
Config,
Runtime,
Expand Down Expand Up @@ -345,6 +350,11 @@ export class Miniflare {
request,
customService
);
} else if (url.pathname === "/core/error") {
const workerSrcOpts = this.#workerOpts.map<SourceOptions>(
({ core }) => core
);
response = await handlePrettyErrorRequest(workerSrcOpts, request);
} else {
// TODO: check for proxying/outbound fetch header first (with plans for fetch mocking)
response = await this.#handleLoopbackPlugins(request, url);
Expand Down
Loading