@qwik.dev/core 2.0.0-beta.36 → 2.0.0-beta.38

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.
@@ -8,6 +8,7 @@
8
8
  * - https://bun.sh/docs/api/http
9
9
  *
10
10
  */
11
+ import { getRequestEvent } from "@qwik.dev/router";
11
12
  import { createQwikRouter } from "@qwik.dev/router/middleware/bun";
12
13
  import render from "./entry.ssr";
13
14
 
@@ -25,7 +26,41 @@ const port = Number(Bun.env.PORT ?? 3000);
25
26
  // eslint-disable-next-line no-console
26
27
  console.log(`Server started: http://localhost:${port}/`);
27
28
 
29
+ // Optional request-aware diagnostics for crashes that escape request boundaries.
30
+ // This does not prevent Bun from crashing, but it does provide better diagnostics.
31
+ // See Bun and Node process event docs for runtime-specific behavior.
32
+ process.on("uncaughtException", (error) => {
33
+ const requestEv = getRequestEvent();
34
+ if (requestEv) {
35
+ console.error("Unhandled exception during request", {
36
+ method: requestEv.method,
37
+ url: requestEv.url.href,
38
+ headersSent: requestEv.headersSent,
39
+ error,
40
+ });
41
+ return;
42
+ }
43
+
44
+ console.error("Unhandled exception outside request", { error });
45
+ });
46
+
47
+ process.on("unhandledRejection", (reason) => {
48
+ const requestEv = getRequestEvent();
49
+ if (requestEv) {
50
+ console.error("Unhandled rejection during request", {
51
+ method: requestEv.method,
52
+ url: requestEv.url.href,
53
+ headersSent: requestEv.headersSent,
54
+ reason,
55
+ });
56
+ return;
57
+ }
58
+
59
+ console.error("Unhandled rejection outside request", { reason });
60
+ });
61
+
28
62
  Bun.serve({
63
+ maxRequestBodySize: 10 * 1024 * 1024,
29
64
  async fetch(request: Request) {
30
65
  const staticResponse = await staticFile(request);
31
66
  if (staticResponse) {
@@ -7,6 +7,7 @@
7
7
  * - https://qwik.dev/docs/deployments/gcp-cloud-run/
8
8
  *
9
9
  */
10
+ import { getRequestEvent } from "@qwik.dev/router";
10
11
  import {
11
12
  createQwikRouter,
12
13
  type PlatformNode,
@@ -77,6 +78,25 @@ const { router, staticFile } = createQwikRouter({
77
78
 
78
79
  const server = createServer();
79
80
 
81
+ // Optional request-aware diagnostics for crashes that escape request boundaries.
82
+ // This does not prevent Node from crashing, but it does provide better diagnostics for uncaught exceptions.
83
+ // See the Node documentation to handle uncaught exceptions and unhandled rejections in your app.
84
+ process.on("uncaughtExceptionMonitor", (error, origin) => {
85
+ const requestEv = getRequestEvent();
86
+ if (requestEv) {
87
+ console.error("Unhandled exception during request", {
88
+ origin,
89
+ method: requestEv.method,
90
+ url: requestEv.url.href,
91
+ headersSent: requestEv.headersSent,
92
+ error,
93
+ });
94
+ return;
95
+ }
96
+
97
+ console.error("Unhandled exception outside request", { origin, error });
98
+ });
99
+
80
100
  server.on("request", (req, res) => {
81
101
  for (const header of Object.entries(DEFAULT_HEADERS)) {
82
102
  res.setHeader(...header);
@@ -8,6 +8,7 @@
8
8
  * - https://docs.deno.com/runtime/tutorials/http_server
9
9
  *
10
10
  */
11
+ import { getRequestEvent } from "@qwik.dev/router";
11
12
  import { createQwikRouter } from "@qwik.dev/router/middleware/deno";
12
13
  import render from "./entry.ssr";
13
14
 
@@ -25,6 +26,46 @@ const port = Number(Deno.env.get("PORT") ?? 3009);
25
26
  /* eslint-disable */
26
27
  console.log(`Server starter: http://localhost:${port}/app/`);
27
28
 
29
+ // Optional request-aware diagnostics for crashes that escape request boundaries.
30
+ // This does not prevent Deno from crashing, but it does provide better diagnostics.
31
+ // See Deno runtime event docs for error and unhandled rejection behavior.
32
+ globalThis.addEventListener("error", (event: ErrorEvent) => {
33
+ const requestEv = getRequestEvent();
34
+ if (requestEv) {
35
+ console.error("Unhandled exception during request", {
36
+ method: requestEv.method,
37
+ url: requestEv.url.href,
38
+ headersSent: requestEv.headersSent,
39
+ error: event.error,
40
+ });
41
+ return;
42
+ }
43
+
44
+ console.error("Unhandled exception outside request", {
45
+ error: event.error,
46
+ });
47
+ });
48
+
49
+ globalThis.addEventListener(
50
+ "unhandledrejection",
51
+ (event: PromiseRejectionEvent) => {
52
+ const requestEv = getRequestEvent();
53
+ if (requestEv) {
54
+ console.error("Unhandled rejection during request", {
55
+ method: requestEv.method,
56
+ url: requestEv.url.href,
57
+ headersSent: requestEv.headersSent,
58
+ reason: event.reason,
59
+ });
60
+ return;
61
+ }
62
+
63
+ console.error("Unhandled rejection outside request", {
64
+ reason: event.reason,
65
+ });
66
+ },
67
+ );
68
+
28
69
  Deno.serve({ port }, async (request: Request, info: any) => {
29
70
  const staticResponse = await staticFile(request);
30
71
  if (staticResponse) {
@@ -7,6 +7,7 @@
7
7
  * - https://qwik.dev/docs/deployments/node/
8
8
  *
9
9
  */
10
+ import { getRequestEvent } from "@qwik.dev/router";
10
11
  import {
11
12
  createQwikRouter,
12
13
  type PlatformNode,
@@ -46,6 +47,25 @@ const { router } = createQwikRouter({
46
47
  // https://expressjs.com/
47
48
  const app = express();
48
49
 
50
+ // Optional request-aware diagnostics for crashes that escape request boundaries.
51
+ // This does not prevent Node from crashing, but it does provide better diagnostics for uncaught exceptions.
52
+ // See the Node documentation to handle uncaught exceptions and unhandled rejections in your app.
53
+ process.on("uncaughtExceptionMonitor", (error, origin) => {
54
+ const requestEv = getRequestEvent();
55
+ if (requestEv) {
56
+ console.error("Unhandled exception during request", {
57
+ origin,
58
+ method: requestEv.method,
59
+ url: requestEv.url.href,
60
+ headersSent: requestEv.headersSent,
61
+ error,
62
+ });
63
+ return;
64
+ }
65
+
66
+ console.error("Unhandled exception outside request", { origin, error });
67
+ });
68
+
49
69
  // Enable gzip compression
50
70
  // app.use(compression());
51
71
 
@@ -7,6 +7,7 @@
7
7
  * - https://qwik.dev/docs/deployments/node/
8
8
  *
9
9
  */
10
+ import { getRequestEvent } from "@qwik.dev/router";
10
11
  import { type PlatformNode } from "@qwik.dev/router/middleware/node";
11
12
  import "dotenv/config";
12
13
  import Fastify from "fastify";
@@ -27,6 +28,25 @@ const assetsDir = join(distDir, "assets");
27
28
  const PORT = parseInt(process.env.PORT ?? "3000");
28
29
  const HOST = process.env.HOST ?? "0.0.0.0";
29
30
 
31
+ // Optional request-aware diagnostics for crashes that escape request boundaries.
32
+ // This does not prevent Node from crashing, but it does provide better diagnostics for uncaught exceptions.
33
+ // See the Node documentation to handle uncaught exceptions and unhandled rejections in your app.
34
+ process.on("uncaughtExceptionMonitor", (error, origin) => {
35
+ const requestEv = getRequestEvent();
36
+ if (requestEv) {
37
+ console.error("Unhandled exception during request", {
38
+ origin,
39
+ method: requestEv.method,
40
+ url: requestEv.url.href,
41
+ headersSent: requestEv.headersSent,
42
+ error,
43
+ });
44
+ return;
45
+ }
46
+
47
+ console.error("Unhandled exception outside request", { origin, error });
48
+ });
49
+
30
50
  const start = async () => {
31
51
  // Create the fastify server
32
52
  // https://fastify.dev/docs/latest/Guides/Getting-Started/
@@ -43,7 +43,16 @@ const qwikPlugin: FastifyPluginAsync<FastifyQwikOptions> = async (
43
43
  fastify.removeAllContentTypeParsers();
44
44
 
45
45
  fastify.setNotFoundHandler(async (request, response) => {
46
- await router(request.raw, response.raw, (err) => fastify.log.error(err));
46
+ await router(
47
+ request.raw,
48
+ response.raw,
49
+ (err) => {
50
+ if (err) {
51
+ response.send(err);
52
+ }
53
+ },
54
+ { bodyLimit: request.routeOptions.bodyLimit },
55
+ );
47
56
  });
48
57
  };
49
58
 
@@ -7,6 +7,7 @@
7
7
  * - https://qwik.dev/docs/deployments/node/
8
8
  *
9
9
  */
10
+ import { getRequestEvent } from "@qwik.dev/router";
10
11
  import { createQwikRouter } from "@qwik.dev/router/middleware/node";
11
12
  import { createServer } from "node:http";
12
13
  import render from "./entry.ssr";
@@ -24,6 +25,25 @@ const { router, staticFile } = createQwikRouter({
24
25
 
25
26
  const server = createServer();
26
27
 
28
+ // Optional request-aware diagnostics for crashes that escape request boundaries.
29
+ // This does not prevent Node from crashing, but it does provide better diagnostics for uncaught exceptions.
30
+ // See the Node documentation to handle uncaught exceptions and unhandled rejections in your app.
31
+ process.on("uncaughtExceptionMonitor", (error, origin) => {
32
+ const requestEv = getRequestEvent();
33
+ if (requestEv) {
34
+ console.error("Unhandled exception during request", {
35
+ origin,
36
+ method: requestEv.method,
37
+ url: requestEv.url.href,
38
+ headersSent: requestEv.headersSent,
39
+ error,
40
+ });
41
+ return;
42
+ }
43
+
44
+ console.error("Unhandled exception outside request", { origin, error });
45
+ });
46
+
27
47
  server.on("request", (req, res) => {
28
48
  staticFile(req, res, () => {
29
49
  router(req, res, () => {});
@@ -17,13 +17,17 @@ declare interface AddRootFn {
17
17
  (obj: unknown, returnRef: true): SeenRef;
18
18
  }
19
19
 
20
- declare type AllSignalFlags = SignalFlags | WrappedSignalFlags | SerializationSignalFlags | AsyncSignalFlags;
20
+ declare type AllSignalFlags = ComputedSignalFlags | SerializationSignalFlags | AsyncSignalFlags;
21
21
 
22
22
  declare const enum AsyncSignalFlags {
23
23
  EAGER_CLEANUP = 32,
24
24
  CLIENT_ONLY = 64,
25
25
  CLEAR_ON_INVALIDATE = 128,
26
- NO_POLL = 256
26
+ NO_POLL = 256,
27
+ /** The compute fn is async: the async engine (jobs, loading, error) is active */
28
+ ASYNC_MODE = 512,
29
+ /** Invoke the compute fn AsyncSignal-style: pass the ComputeCtx argument, no auto-tracking */
30
+ CTX_ARG = 1024
27
31
  }
28
32
 
29
33
  /** Class for back reference to the EffectSubscription */
@@ -56,6 +60,12 @@ declare const enum ChoreBits {
56
60
  DIRTY_MASK = 1023
57
61
  }
58
62
 
63
+ declare const enum ComputedSignalFlags {
64
+ INVALID = 1,
65
+ RUN_EFFECTS = 2,
66
+ PRESERVE_ON_SEQ_CLEANUP = 4
67
+ }
68
+
59
69
  /** @internal */
60
70
  declare const _CONST_PROPS: unique symbol;
61
71
 
@@ -190,15 +200,6 @@ export declare const createDOM: ({ html }?: {
190
200
  userEvent: (queryOrElement: string | Element | keyof HTMLElementTagNameMap | null, eventNameCamel: string | keyof WindowEventMap, eventPayload?: any) => Promise<Event | null>;
191
201
  }>;
192
202
 
193
- declare interface DescriptorBase<T = unknown, B = unknown> extends BackRef {
194
- $flags$: number;
195
- $index$: number;
196
- $el$: HostElement;
197
- $qrl$: QRLInternal<T>;
198
- $state$: B | undefined;
199
- $destroy$: (() => void) | null;
200
- }
201
-
202
203
  /** @public */
203
204
  declare interface DevJSX {
204
205
  fileName: string;
@@ -226,6 +227,7 @@ declare const _EFFECT_BACK_REF: unique symbol;
226
227
 
227
228
  declare type EffectBackRef = SignalImpl | StoreTarget | PropsProxy;
228
229
 
230
+ /** @internal */
229
231
  declare const enum EffectProperty {
230
232
  COMPONENT = ":",
231
233
  VNODE = "."
@@ -324,6 +326,7 @@ declare type FunctionComponent<P = unknown> = {
324
326
  /** @public */
325
327
  export declare function getTestPlatform(): TestPlatform;
326
328
 
329
+ /** @internal */
327
330
  declare type HostElement = VNode | ISsrNode;
328
331
 
329
332
  /** @public */
@@ -676,6 +679,8 @@ declare type QRL<TYPE = unknown> = {
676
679
 
677
680
  declare type QrlArgs<T> = T extends (...args: infer ARGS) => any ? ARGS : unknown[];
678
681
 
682
+ declare type QrlCaptures = Readonly<unknown[]> | string | null;
683
+
679
684
  /** @public */
680
685
  declare interface QRLDev {
681
686
  file: string;
@@ -690,8 +695,8 @@ declare type QRLInternalMethods<TYPE> = {
690
695
  readonly $chunk$: string | null;
691
696
  readonly $symbol$: string;
692
697
  readonly $hash$: string;
693
- /** If it's a string it's serialized */
694
- readonly $captures$?: Readonly<unknown[]> | string | null;
698
+ /** Captures are stored lazily after deserialization. */
699
+ readonly $captures$?: QrlCaptures;
695
700
  dev?: QRLDev | null;
696
701
  resolve(container?: Container): Promise<TYPE>;
697
702
  resolved: undefined | TYPE;
@@ -708,7 +713,7 @@ declare type QRLInternalMethods<TYPE> = {
708
713
  * method but we need to have a stable name because it gets called in user code by the optimizer,
709
714
  * after the $name$ props are mangled
710
715
  */
711
- w(captures: Readonly<unknown[]> | string | null): QRLInternal<TYPE>;
716
+ w(captures: QrlCaptures): QRLInternal<TYPE>;
712
717
  /**
713
718
  * "set ref" - Set the ref of the QRL. It's an internal method but we need to have a stable name
714
719
  * because it gets called in user code by the optimizer, after the $name$ props are mangled
@@ -817,11 +822,6 @@ declare interface Signal<T = any> {
817
822
  trigger(): void;
818
823
  }
819
824
 
820
- declare const enum SignalFlags {
821
- INVALID = 1,
822
- RUN_EFFECTS = 2
823
- }
824
-
825
825
  declare class SignalImpl<T = any> implements Signal<T> {
826
826
  $untrackedValue$: T;
827
827
  /** Store a list of effects which are dependent on this signal. */
@@ -857,11 +857,13 @@ declare interface SimplifiedServerRequestEvent<T = unknown> {
857
857
  declare interface SSRInternalStreamWriter extends StreamWriter_2 {
858
858
  writeRootRef(id: number): ValueOrPromise<void>;
859
859
  writeRootRefPath(path: number[]): ValueOrPromise<void>;
860
+ writeRootRefDelta(id: number, base: number): ValueOrPromise<void>;
860
861
  toString(remap?: number[]): string;
861
862
  }
862
863
 
863
864
  declare const enum SsrNodeFlags {
864
- Updatable = 1
865
+ Updatable = 1,
866
+ WarnedStreamedChore = 2
865
867
  }
866
868
 
867
869
  /** @public */
@@ -874,6 +876,8 @@ export declare function ssrRenderToDom(jsx: JSXOutput, opts?: {
874
876
  qwikLoader?: boolean;
875
877
  /** Override the SSR container tag name. */
876
878
  containerTagName?: string;
879
+ /** Root-count threshold for eager yielded state prewarm during client resume. */
880
+ statePrewarm?: number | false;
877
881
  /** Stream rendered chunks while still collecting the final HTML. */
878
882
  stream?: StreamWriter;
879
883
  /** Configure SSR streaming. */
@@ -911,20 +915,30 @@ declare class SubscriptionData {
911
915
 
912
916
  declare type SymbolToChunkResolver = (symbol: string) => string;
913
917
 
914
- declare class Task<T = unknown, B = T> extends BackRef implements DescriptorBase<unknown, Signal<B>> {
915
- $flags$: number;
918
+ /** @internal */
919
+ declare class Task<T = unknown, B = T> extends BackRef {
920
+ $flags$: TaskFlags;
916
921
  $index$: number;
917
922
  $el$: HostElement;
918
923
  $qrl$: QRLInternal<T>;
919
- $state$: Signal<B> | undefined;
920
924
  $destroy$: (() => void) | null;
921
925
  $destroyPromise$: Promise<void> | undefined;
922
926
  $taskPromise$: Promise<void> | null;
923
- constructor($flags$: number, $index$: number, $el$: HostElement, $qrl$: QRLInternal<T>, $state$: Signal<B> | undefined, $destroy$: (() => void) | null);
927
+ constructor($flags$: TaskFlags, $index$: number, $el$: HostElement, $qrl$: QRLInternal<T>, $destroy$: (() => void) | null);
924
928
  }
925
929
 
926
930
  declare const TaskEvent = "qTask";
927
931
 
932
+ /** @internal */
933
+ declare const enum TaskFlags {
934
+ VISIBLE_TASK = 1,
935
+ TASK = 2,
936
+ DIRTY = 4,
937
+ RENDER_BLOCKING = 8,
938
+ NEEDS_CLEANUP = 16,
939
+ EVENTS_REGISTERED = 32
940
+ }
941
+
928
942
  /** @public */
929
943
  declare interface TestPlatform extends CorePlatform {
930
944
  /**
@@ -992,7 +1006,7 @@ declare abstract class VNode implements BackRef {
992
1006
 
993
1007
  /** @public */
994
1008
  export declare function vnode_fromJSX(jsx: JSXOutput): {
995
- vParent: _VirtualVNode | _ElementVNode;
1009
+ vParent: _ElementVNode | _VirtualVNode;
996
1010
  vNode: _VNode | null;
997
1011
  document: _QDocument;
998
1012
  container: ClientContainer_2;
@@ -1099,10 +1113,6 @@ export declare function walkJSX(jsx: JSXOutput, apply: {
1099
1113
  text: (text: _Stringifiable) => void;
1100
1114
  }): void;
1101
1115
 
1102
- declare const enum WrappedSignalFlags {
1103
- UNWRAP = 4
1104
- }
1105
-
1106
1116
  declare class WrappedSignalImpl<T> extends SignalImpl<T> {
1107
1117
  $args$: any[];
1108
1118
  $func$: (...args: any[]) => T;
@@ -1110,7 +1120,7 @@ declare class WrappedSignalImpl<T> extends SignalImpl<T> {
1110
1120
  $flags$: AllSignalFlags;
1111
1121
  $hostElement$: HostElement | undefined;
1112
1122
  [_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | undefined;
1113
- constructor(container: Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: SignalFlags);
1123
+ constructor(container: Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: AllSignalFlags);
1114
1124
  invalidate(): void;
1115
1125
  get untrackedValue(): T;
1116
1126
  $computeIfNeeded$(): void;