Skip to content
Closed
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
5 changes: 0 additions & 5 deletions .changeset/chilly-rabbits-lie.md

This file was deleted.

23 changes: 0 additions & 23 deletions apps/tests/src/routes/server-function-file.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions apps/tests/src/routes/server-function-iterator.tsx

This file was deleted.

28 changes: 4 additions & 24 deletions apps/tests/src/routes/server-function-ping.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
import { createEffect, createSignal } from "solid-js";

async function sleep(value: unknown, ms: number) {
return new Promise((res) => {
setTimeout(res, ms, value);
})
}

async function ping(value: Date) {
async function ping(value: string) {
"use server";

const current = [
value,
{
name: 'example',
async *[Symbol.asyncIterator]() {
yield sleep('foo', 5000);
yield sleep('bar', 5000);
yield sleep('baz', 5000);
}
}
];

return current;
return await Promise.resolve(value);
}

export default function App() {
const [output, setOutput] = createSignal<{ result?: boolean }>({});

createEffect(async () => {
const value = new Date();
const value = `${Math.random() * 1000}`;
const result = await ping(value);
await ping(value);
console.log(result);
setOutput((prev) => ({ ...prev, result: value.toString() === result[0].toString() }));
setOutput(prev => ({ ...prev, result: value === result }));
});

return (
Expand Down
38 changes: 0 additions & 38 deletions apps/tests/src/routes/server-function-plugin.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions apps/tests/src/routes/server-function-readable-stream.tsx

This file was deleted.

1 change: 0 additions & 1 deletion apps/tests/src/routes/treeshaking/(no-side-effects).tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createAsync } from "@solidjs/router";
import { createEffect } from "solid-js";

const a = "myTreeshakingTestUniqueString1";

Expand Down
2 changes: 1 addition & 1 deletion packages/start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"solid-js": "^1.9.11",
"source-map-js": "^1.2.1",
"srvx": "^0.12.0",
"terracotta": "^1.1.1",
"terracotta": "^1.1.0",
"vite-plugin-solid": "^2.11.11"
},
"engines": {
Expand Down
21 changes: 8 additions & 13 deletions packages/start/src/fns/client.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { type Component } from "solid-js";
import { pushRequest, pushResponse } from "../shared/dev-toolbar/functions/tracker.ts";
import {
// serializeToJSONStream,
serializeToJSONString,
} from "./serialization.ts";
import { BODY_FORMAT_KEY, BodyFormat, extractBody, getHeadersAndBody } from "./shared.ts";
import {
BODY_FORMAT_KEY,
BodyFormat,
extractBody,
getHeadersAndBody,
} from "./shared.ts";

let INSTANCE = 0;

async function createRequest(base: string, id: string, instance: string, options: RequestInit) {
const request = new Request(base, {
function createRequest(base: string, id: string, instance: string, options: RequestInit) {
return fetch(base, {
method: "POST",
...options,
headers: {
Expand All @@ -18,15 +22,6 @@ async function createRequest(base: string, id: string, instance: string, options
"X-Server-Instance": instance,
},
});
if (import.meta.env.DEV) {
console.log(pushRequest);
pushRequest(id, instance, request.clone());
}
const response = await fetch(request);
if (import.meta.env.DEV) {
pushResponse(id, instance, response.clone());
}
return response;
}

async function initializeResponse(
Expand Down
27 changes: 8 additions & 19 deletions packages/start/src/fns/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export async function handleServerFunction(h3Event: H3Event) {
h3Event.res.headers.set("content-type", "text/javascript");
return serializeToJSStream(instance, result);
}
h3Event.res.headers.set("content-type", "text/plain");
return serializeToJSONStream(result);
} catch (x) {
if (x instanceof Response) {
Expand All @@ -133,18 +134,14 @@ export async function handleServerFunction(h3Event: H3Event) {
// forward headers
if ((x as any).headers) mergeResponseHeaders(h3Event, (x as any).headers);
// forward non-redirect statuses
if (
(x as any).status &&
(!instance || (x as any).status < 300 || (x as any).status >= 400)
)
if ((x as any).status && (!instance || (x as any).status < 300 || (x as any).status >= 400))
h3Event.res.status = (x as any).status;
if ((x as any).customBody) {
x = await (x as any).customBody();
} else if ((x as any).body == null) x = null;
h3Event.res.headers.set("X-Error", "true");
} else if (instance) {
const error =
x instanceof Error ? x.message : typeof x === "string" ? x : "true";
const error = x instanceof Error ? x.message : typeof x === "string" ? x : "true";

h3Event.res.headers.set("X-Error", toHeaderValue(error));
} else {
Expand All @@ -167,6 +164,7 @@ export async function handleServerFunction(h3Event: H3Event) {
h3Event.res.headers.set("content-type", "text/javascript");
return serializeToJSStream(instance, x);
}
h3Event.res.headers.set("content-type", "text/plain");
return serializeToJSONStream(x);
}
return x;
Expand Down Expand Up @@ -194,10 +192,7 @@ function handleNoJS(result: any, request: Request, parsed: any[], thrown?: boole
if (result.headers.has("Location")) {
headers.set(
`Location`,
new URL(
result.headers.get("Location")!,
url.origin + import.meta.env.BASE_URL,
).toString(),
new URL(result.headers.get("Location")!, url.origin + import.meta.env.BASE_URL).toString(),
);
statusCode = getExpectedRedirectStatus(result);
}
Expand All @@ -214,10 +209,7 @@ function handleNoJS(result: any, request: Request, parsed: any[], thrown?: boole
result: isError ? result.message : result,
thrown: thrown,
error: isError,
input: [
...parsed.slice(0, -1),
[...parsed[parsed.length - 1].entries()],
],
input: [...parsed.slice(0, -1), [...parsed[parsed.length - 1].entries()]],
}),
)}; Secure; HttpOnly;`,
);
Expand All @@ -243,7 +235,7 @@ export function createSingleFlightHeaders(sourceEvent: FetchEvent) {
// useH3Internals = true;
// sourceEvent.nativeEvent.node.req.headers.cookie = "";
// }
SetCookies.forEach((cookie) => {
SetCookies.forEach(cookie => {
if (!cookie) return;
const { maxAge, expires, name, value } = parseSetCookie(cookie);
if (maxAge != null && maxAge <= 0) {
Expand All @@ -264,10 +256,7 @@ export function createSingleFlightHeaders(sourceEvent: FetchEvent) {

return headers;
}
async function handleSingleFlight(
sourceEvent: FetchEvent,
result: any,
): Promise<Response> {
async function handleSingleFlight(sourceEvent: FetchEvent, result: any): Promise<Response> {
let revalidate: string[];
let url = new URL(sourceEvent.request.headers.get("referer")!).toString();
if (result instanceof Response) {
Expand Down
2 changes: 1 addition & 1 deletion packages/start/src/fns/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function serializeToJSONStream(value: any) {
});
}

export class SerovalChunkReader {
class SerovalChunkReader {
reader: ReadableStreamDefaultReader<Uint8Array>;
buffer: Uint8Array;
done: boolean;
Expand Down
6 changes: 3 additions & 3 deletions packages/start/src/shared/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// @refresh skip
import { catchError, ErrorBoundary as DefaultErrorBoundary, type ParentProps } from "solid-js";
import { ErrorBoundary as DefaultErrorBoundary, catchError, type ParentProps } from "solid-js";
import { isServer } from "solid-js/web";
import { DevToolbar } from "./dev-toolbar/index.tsx";
import { HttpStatusCode } from "./HttpStatusCode.ts";
import { DevOverlay } from "./dev-overlay/index.tsx";

export const ErrorBoundary =
import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY
? (props: ParentProps) => <DevToolbar>{props.children}</DevToolbar>
? (props: ParentProps) => <DevOverlay>{props.children}</DevOverlay>
: (props: ParentProps) => {
const message = isServer
? "500 | Internal Server Error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function CodeView(props: CodeViewProps): JSX.Element | null {
for (let i = 0, len = lines.length; i < len; i++) {
const el = lines[i] as HTMLElement;
if (props.line - minLine() - 1 === i) {
el.dataset.startErrorViewerErrorLine = '';
el.dataset.startDevOverlayErrorLine = '';
}
}
}
Expand All @@ -81,9 +81,9 @@ export function CodeView(props: CodeViewProps): JSX.Element | null {
return (
<div
ref={ref}
data-start-error-viewer-code-view
data-start-dev-overlay-code-view
style={{
"--error-viewer-code-view-start": minLine() + 1,
"--dev-overlay-code-view-start": minLine() + 1,
}}
/>
);
Expand Down
Loading
Loading