@solidjs/start 2.0.0-rc.6 → 2.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/config/index.d.ts +34 -11
- package/dist/fns/error-handler.d.ts +31 -1
- package/dist/fns/error-handler.js +0 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/config/index.d.ts
CHANGED
|
@@ -115,22 +115,45 @@ export interface SolidStartOptions {
|
|
|
115
115
|
*/
|
|
116
116
|
env?: EnvPluginOptions;
|
|
117
117
|
/**
|
|
118
|
-
* Options
|
|
119
|
-
* (inclusion / exclusion filters
|
|
118
|
+
* Options for server functions: which files the `"use server"` transform
|
|
119
|
+
* processes (inclusion / exclusion filters), and what happens when a server
|
|
120
|
+
* function throws.
|
|
120
121
|
*/
|
|
121
122
|
serverFunctions?: Pick<ServerFunctionsOptions, "filter"> & {
|
|
122
123
|
/**
|
|
123
|
-
* Path to a module whose default export
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
124
|
+
* Path to a module whose default export handles whatever a server function
|
|
125
|
+
* throws, before it reaches the client. Use it to report failures to a
|
|
126
|
+
* monitoring service, or to replace an error carrying internal detail with
|
|
127
|
+
* one that is safe to send.
|
|
127
128
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
129
|
+
* Only server function calls made over the network run through it. A
|
|
130
|
+
* server function called during rendering runs in process and throws
|
|
131
|
+
* straight to its caller, and errors from API routes never reach it
|
|
132
|
+
* either.
|
|
131
133
|
*
|
|
132
|
-
* The
|
|
133
|
-
*
|
|
134
|
+
* The export is called synchronously with the thrown value, and what it
|
|
135
|
+
* returns decides what the client sees:
|
|
136
|
+
*
|
|
137
|
+
* - `undefined` (or `null`) sends what was thrown, unchanged.
|
|
138
|
+
* - A `Response` is passed through unchanged, which keeps a thrown
|
|
139
|
+
* `redirect()` working.
|
|
140
|
+
* - Any other value is sent in place of what was thrown, and the client
|
|
141
|
+
* call rejects with it.
|
|
142
|
+
*
|
|
143
|
+
* Control flow reaches the export the same way errors do, so a handler
|
|
144
|
+
* that replaces everything it sees turns redirects into errors.
|
|
145
|
+
*
|
|
146
|
+
* Whatever is sent gets serialized to the client along with its own
|
|
147
|
+
* properties, so an error meant to be safe to expose must not carry
|
|
148
|
+
* internal detail.
|
|
149
|
+
*
|
|
150
|
+
* The return value is not awaited, so make the export a plain function
|
|
151
|
+
* rather than an `async` one, and report failures with calls that do not
|
|
152
|
+
* need awaiting.
|
|
153
|
+
*
|
|
154
|
+
* Type the export as `ServerFunctionErrorHandler` from
|
|
155
|
+
* `@solidjs/start/server`. The module is bundled into the server only, so
|
|
156
|
+
* it may import server-only code such as a monitoring SDK.
|
|
134
157
|
*
|
|
135
158
|
* @example "src/server-fn-error.ts"
|
|
136
159
|
*/
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles whatever a server function threw, before it reaches the client. Use
|
|
3
|
+
* it to type the default export of the module named by the
|
|
4
|
+
* `serverFunctions.onError` option in `vite.config.ts`.
|
|
5
|
+
*
|
|
6
|
+
* Called synchronously, and the value it returns is not awaited, so it cannot
|
|
7
|
+
* be an `async` function.
|
|
8
|
+
*
|
|
9
|
+
* @param thrown The value the server function threw. This is a `Response` when
|
|
10
|
+
* the server function threw control flow such as a `redirect()`.
|
|
11
|
+
* @returns `undefined` (or `null`) to send `thrown` unchanged, a `Response` to
|
|
12
|
+
* pass control flow through untouched, or any other value to send in place of
|
|
13
|
+
* `thrown`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // src/server-fn-error.ts
|
|
18
|
+
* import type { ServerFunctionErrorHandler } from "@solidjs/start/server";
|
|
19
|
+
* import { captureException } from "./your-monitoring-client";
|
|
20
|
+
*
|
|
21
|
+
* const onServerFunctionError: ServerFunctionErrorHandler = thrown => {
|
|
22
|
+
* // redirect() throws a Response, so returning it preserves that control flow.
|
|
23
|
+
* if (thrown instanceof Response) return thrown;
|
|
24
|
+
*
|
|
25
|
+
* captureException(thrown); // or console.error, or any reporter
|
|
26
|
+
* return new Error("Something went wrong");
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* export default onServerFunctionError;
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
1
32
|
export type ServerFunctionErrorHandler = (thrown: unknown) => unknown;
|
|
2
|
-
/** @internal */
|
|
3
33
|
export declare function applyServerFunctionErrorHandler(thrown: unknown): unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/solidjs/solid-start.git",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"path-to-regexp": "^8.4.2",
|
|
49
49
|
"pathe": "^2.0.3",
|
|
50
50
|
"radix3": "^1.1.2",
|
|
51
|
-
"seroval": "^1.
|
|
52
|
-
"seroval-plugins": "^1.
|
|
51
|
+
"seroval": "^1.6.0",
|
|
52
|
+
"seroval-plugins": "^1.6.0",
|
|
53
53
|
"shiki": "^4.3.1",
|
|
54
54
|
"solid-js": "^1.9.14",
|
|
55
55
|
"source-map-js": "^1.2.1",
|